안동 안개 데이터
35차원 --> 2차원
PCA 적용 전후, 정확도 차이 없음. 똑같음
kernel PCA 적용 전후, 정확도 차이 없음. 똑같음


안동 안개 데이터
35차원 --> 2차원
PCA 적용 전후, 정확도 차이 없음. 똑같음
kernel PCA 적용 전후, 정확도 차이 없음. 똑같음
백신 프로그램이 임시 저장 폴더에서 이동을 금지시킨 것이 원인
백신을 잠시 끄고 실행시키면 정상적으로 설치가 진행됨.
참조: https://m.blog.naver.com/jjy0501/221300556843
R 패키지 설치 및 업데이트 오류 (1)
R 패키지를 설치하거나 업데이트 하다보면 여러 가지 문제가 생기는 경우들이 있습니다. 이 ...
blog.naver.com
쌩뚱맞은 microsoft.com 에러?
에러 발생
> install.packages("ggplot2")
Warning in install.packages :
unable to access index for repository https://mran.microsoft.com/snapshot/2020-07-16/src/contrib:
URL 'https://mran.microsoft.com/snapshot/2020-07-16/src/contrib/PACKAGES'를 열 수 없습니다
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/chpark/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository https://mran.microsoft.com/snapshot/2020-07-16/src/contrib:
URL 'https://mran.microsoft.com/snapshot/2020-07-16/src/contrib/PACKAGES'를 열 수 없습니다
Warning in install.packages :
package ‘ggplot2’ is not available (for R version 4.0.2)
Warning in install.packages :
unable to access index for repository https://mran.microsoft.com/snapshot/2020-07-16/bin/windows/contrib/4.0:
URL 'https://mran.microsoft.com/snapshot/2020-07-16/bin/windows/contrib/4.0/PACKAGES'를 열 수 없습니다
해결
아래 script 실행
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.r-project.org"
options(repos=r)})
이후
> install.packages("ggplot2")
실행하면 됨
Unable to access MRAN: is there currently any problem on your server? - Microsoft Q&A
Hello, I tried to install a package today from MRAN but it failed. Here is the error message: Warning in install.packages : unable to access index for repository https://mran.microsoft.com/snapshot/2020-07-16/src/contrib: cannot open URL…
learn.microsoft.com
XGBOOST 작업 중 모델링 시간 측정 코드
# ## 4.4.4 시간 측정 (115)
# from sklearn.ensemble import GradientBoostingClassifier
# from xgboost import XGBClassifier
# from sklearn.metrics import accuracy_score
# import time
# start = time.time()
# df.info()
# end=time.time()
# elapsed = end - start
# print('\n실행시간: ' + str(elapsed) + '초')
# ## 4.4.5 속도비교(152)
# %timeit -n 100 -r 3 sum(np.square(range(10000)))
# %%timeit -n 100 -r 3
# summing = 0
# for i in range(10000):
# summing += i**2
# ## 그레디언트 부스팅 분류
# # 모델크기 제한을 위해서 max_depth =2, n_estimator=100 으로 설정
# start = time.time()
# gbr = GradientBoostingClassifier(n_estimators = 100, max_depth = 2, random_state=2)
# gbr.fit(X_train, y_train)
# y_pred = gbr.predict(X_test)
# score = accuracy_score(y_pred, y_test)
# print('점수: ' + str(score))
# end = time.time()
# elapsed = end-start
# print('실행시간: ' + str(elapsed) + '초')
## XGB 분류
# ### 부스팅 분야에서 타의 추종을 불허하는 속도를 보이는 모델. GPU_0에서 30배 빠름
# start = time.time()
# xg_reg = XGBClassifier(n_estimators=100, max_depth=2, use_label_encoder=False)
# xg_reg.fit(X_train, y_train)
# y_pred = xg_reg.predict(X_test)
# score = accuracy_score(y_pred, y_test)
# print('점수 : ' +str(score))
# end = time.time()
# elapsed=end-start
# print('실행 시간: ' +str(elapsed) + '초')
에러
TypeError: 'int' object is not iterable
코드
n_row = len(din['Phen_fog'])-1
print(n_row)
for i in n_row:
if i == 1:
print(i)
원인
for i in n_row: 에서 n_row 가 list 이어야 하는데, 여기서는 정수(int)로만 되어 있음.
다른 언어에서는 for i in (initial, end , increment) 형태로 되나, Python 에서는 배열 전체가 list 로 들어가 있어야 함.
해결
아래와 같이, din['Phen_fog'] 로 수정하면 에러 해결
for i in din['Phen_fog']:
if i == 1:
print(i)
1. 정확도
실제와 에측이 얼마나 일치하는가로 모델의 성능을 평가함
연속형 자료의 경우
예측값의 일치도를 의미.
정확도가 평가의 대부분임
범주형 자료의 경우
예측 범주의 일치정도를 의미.
정확도 뿐 아니라 그 이면을 세세하게 검토해야 함.
2. 오차행렬(confusion matrix)
오차 행렬은 이진 또는 다중 범주형 레이블의 하위 범주는 세부적으로 살펴보면서 실제 범주와 예측 범주의 일치 혹은 오류를 파악할 수 있는 결과임
0 | 1 | |
0 | 90 | 10 |
1 | 20 | 80 |
음성예측 | 양성예측 | |
음성 클래스 | TN | FP |
양성 클래스 | FN | TP |
정확도 = (90+80)/200 = 85%
이진 분류의 평가 지표
3. 정밀도
양성 예측의 정확도를 의미
4. 재현율
분류기가 정확하게 예측한 양성 샘플의 비율
민감도 또는 진짜 양성 비율이라고도 함.
암진단/범죄여부/불법영상 진단 등
5. f-score
정밀도와 재현율의 조화평균으로 두 지표를 종합적으로 파악
정밀도 = TP/(TP + FP)
재현율 = TP/(TP+FN)
f-score = 2/((1/정밀도) + (1/재현율))
다양한 의사결정 결로와 결과를 놓고 나무 구조를 이용하여 설명하는 것
질문을 던지면서 대상에 접근해 가는 스무고개 놀이와 유사
질문은 조건을 이분법적으로 제시하면서 진행한다.
지도학습 기법으로서 변수의 영역을 게속적으로 분할해 나가면서 집단을 몇개의 소집단으로 분류하거나 예측하는 기법
맨 위쪽에 뿌리 노드로 시작해서 아래로 가면서 가지를 치고 마지막까지 진행한다.
처음에 어떤 분류기준을 선택할 것인가를 결정하는 것은 여러 알고리즘이 있다.
예를 들어, 프로 야구선수중에서 자유게약 선수(Free Agaent: FA)의 연봉을 의사결정 나무로 간단히 그려보자.
의사결저과정에서 나무를 가지고 목표와상황과 상호 관련성을 나타내어 최종 결정을 내린다. 의사결정 규칙을 나물 구조로 도식화 하여 관심대상의 집단을 몇 개의 소집단으로 분류하거나 예측할 수 있다.
if-else 원리로 코딩할 수 있다.
일반적으로 기업에서 의사결정을 내릴때, 어떠한 위험(손실)과 기회(이익)가 있는지 판단하여 최적의 의사결정을 도와주는 프로그램으로 많이 활용한다.
나무 모형 구축: 분석 목적과 자료구조에 따라 적절한 분리기준과 정지규칙을 정하여 나무를 만들어 나간다.
가지치기 : 분류 오류를 크게 할 위험이 높거나 부적절한 추론규칙이 내재된 가지는 제거한다.
분리작업: 더 이상 유효하지 않거나 최소 노드수에 도달할 때까지 분리를 계속한다.
타당성 평가: 이익 또는 위험 도표나 검정자료를 이용하여 나무 모형의 교차 타당성을 평가한다.
해석과 예측: 결과를 해석하고 예측을 수행한다.
시각적인 효과는 행동의 결정 뿐만 아니라 미래의 계획을 세우는 데도 유용하게 사용될 수 있다.
그래서 의사결정나무를 적합성나무(relevance tree)라고도 부른다.
https://machinelearningmastery.com/avoid-overfitting-by-early-stopping-with-xgboost-in-python/
Avoid Overfitting By Early Stopping With XGBoost In Python
Overfitting is a problem with sophisticated non-linear learning algorithms like gradient boosting. In this post you will discover how you can use early stopping to limit overfitting with XGBoost in Python. After reading this post, you will know: About earl
machinelearningmastery.com
print(len(df))
date_data = pd.date_range(start='2016-01-01', end='2022-01-01', freq='H')
dat = date_data.to_list()
print(len(dat)-1)
52608
52608
tmp = pd.merge(asos, aaos, how="outer")
print(len(tmp))
52608
앞에서 만든 1시간 간격 날짜 데이터에 맞춰서 merge 됨.
tmp = pd.merge(asos, aaos, on="Date")
print(len(tmp))
51385
#주의 !! on='Date'를 사용하면 Date 51385 로 자료 없는 곳은 생략하고 merge 됨.
에러
XGBRegression 모델링 에서 발생
UserWarning: Scoring failed. The score on this train-test partition for these parameters will be set to nan. Details:
증상:
nan 으로 나옴
def regression_model(model):
scores = cross_val_score(model, X_train_std, y_train, scoring='neg_mean_squared_error', cv=kfold)
# scores = cross_val_score(model, X, y, scoring='mean_squared_error', cv=kfold)
rmse = (-scores)**0.5
return rmse.mean()
from xgboost import XGBRegressor
from sklearn.model_selection import cross_val_score
regression_model(XGBRegressor(booster='gblinear'))
해결
위 코드 실행 전에 X에 대해서 표준화를 반드시 할 것!!!!
# 데이터 표준화 X 에 대해서만!!!
from sklearn.preprocessing import StandardScaler
std_scale = StandardScaler()
std_scale.fit(X_train)
X_train_std = std_scale.transform(X_train)
X_test_std = std_scale.transform(X_test)
* Keras에서 학습을 시킬 때 fit()과 fit_generator()의 차이점
- fit()은 sklearn의 fit method와 비슷하다. 전체 dataset을 한번에 fit method로 통과시킨다. 따라서 전체 dataset을 메모리에 로드할 수 있는, 작은 크기의 dataset으로 학습을 시킬때 사용한다.
- fit_generator()는 x와 y를 직접적으로 통과시키지 않고, generator를 통해 데이터를 불러온다. kears 공식 문서를 보면, generator는 Multiprocessing을 진행할 때 데이터 중복을 막기 위해서 사용한다. 이것은 practical purpose를 위한 것이며, 큰 크기의 dataset으로 학습을 시킬때 사용한다.
[출처] Keras에서 fit() and fit_generator()|작성자 킵
DevelopLog - 개발로그 : 네이버 블로그
당신의 모든 기록을 담는 공간
blog.naver.com
자료
6 km (0.05 x 0.05 도) ; 1, 3, 24 h 자료 있음.
http://podaac.jpl.nasa.gov/dataset/GOES_L3_SST_6km_NRT_SST_24HOUR
0.083 도 약 8~9 km. 6시간 간격
ftp://polar.ncep.noaa.gov/pub/history/sst/ophi
Daily SST data (0.25 x 0.25 도); 24시간 간격
https://iridl.ldeo.columbia.edu/SOURCES/.NOAA/.NCDC/.OISST/.version2/.AVHRR/.sst/
https://www.ncdc.noaa.gov/thredds/oisst-catalog.html
ftp://polar.ncep.noaa.gov/pub/history/sst/ophi
Edit namelist.wps
$ ./geogrid.exe
Edit namelist.wps
$ ln -sf ./ungrib/Variable_Tables/Vtable.NARR ./Vtable
$ ./link_grib.csh NARR_3D
GRIBFILE 확인
$ ./ungrib.exe
Edit namelist.wps
$ ./link_grib.csh NARR_SFC
GRIBFILE 확인
$ ./ungrib.exe
Edit namelist.wps
$ ln -sf ./ungrib/Variable_Tables/Vtable.SST ./Vtable
$ ./link_grib.sh SST
GRIBFILE 확인 *******중요
$ ./ungrib.exe
Edit namelist.wps
Fg_name = 'NARR_3D', 'NARR_SFC', 'SST' ****** 이 3개를 한꺼번에 metgrid.exe 해야 됨.
Io_form_auxinput4 = 2
Auxinput4_inname = "wrflowinp_d<domain>" (creadted by real.exe)
Auxinput4_interval = 360, 360, 360,
filtered_df = df[df["Date"].isin(pd.date_range('2020-08-25', '2020-08-27'))] ## 날짜별로 구분해서 출력
print(filtered_df)