Python

Python

[python][scikit-learn] KBinsDiscretizer 이용해서 Discretization 하기

scikit-learn.preprocessing 에서 KBinsDiscretizer 를 이용해서 Discretization 하기 continuous variable을 grouping 할 때 유용함 continuous 단일 column을 이용해서 grouping bins=2일때 세가지 방법 쉽게 이해하기 #1. strategy = 'uniform' #2. strategy = 'quantile' #3. strategy = 'kmeans' purpose : y_train_pd 라는 데이터프레임의 pred-true라는 column으로 grouping #0. data train_pt = pd.DataFrame(y_train_pd['pred-true']) #1. strategy = 'uniform' : mean 기..

Python

[python][matplotlib] 에러바 그리기matplotlib.pyplot.errorbar

#0. 소스데이터 #1. 에러바 그리기 #plot errorbar plt.rcParams['figure.figsize']=(15,7) plt.errorbar(x=y_train_gb.index, y=y_train_gb['pred-true_mean'], yerr=y_train_gb['pred-true_std']) plt.title('mean error(pred_eGFR - true_eGFR) in trainset') plt.xlabel('round_eGFR') plt.ylabel('mean error') plt.show()

Python

[python][pandas] 판다스 그룹 집계하기pandas.DataFrame.groupby.aggregate

#0 소스데이터 #1 col1기준으로 그룹핑한 데이터의 집계 df.groupby('col1').agg(['size', 'mean', 'std', 'min', 'max']) y_train_gb = y_train_pd.groupby('round_eGFR').agg(['size', 'mean', 'std', 'min', 'max']) y_train_gb #2 column별 원하는 집계 사용가능 df.groupby('col1').agg({'col1' : ['size'], 'col2' : ['size', 'mean'], 'col3' : ['std'], 'col4' : ['min', 'max']}) y_train_gb = y_train_pd.groupby('round_eGFR').agg({'true_eGFR' : ..

Python

[jupyter] [python] ipynb to HTML, ipynb형식 파일 HTML로 변환하기

ipynb to HTML $ jupyter nbconvert --to html filename.ipynb output

Python

[python] Oversampling, SMOTE –ADASYN

imbalanced dataset을 이용해서 maching learning modeling을 할때 크게 두가지 방법이 있음 1. hyperparameter tuning 과정에서 scale weight 2. oversampling Oversampling 기법으로 SMOTE(synthetic minority oversampling technique)가 일반적으로 많이 쓰임 그 일환으로 ADASYN(Adaptive synthetic sampling approach for imbalanced learning)을 이용해서 oversampling 해보겠음. #1 데이터 준비 X_train_features_imputed.info() #2 ADASYN 이용 oversampling - hyper parameter에서 s..

Python

[python] jupyter notebook shortcut 주피터 노트북 단축키 모음

Command Mode (press Esc to enable) Enter : enter edit mode Shift-Enter : run cell, select below Ctrl-Enter : run cell Alt-Enter : run cell, insert below Y : to code M : to markdown R : to raw 1 : to heading 1 2 : to heading 2 3 : to heading 3 4 : to heading 4 5 : to heading 5 6 : to heading 6 Up : select cell above K : select cell above Down : select cell below J : select cell below A : insert c..

Chandler.j
'Python' 카테고리의 글 목록 (5 Page)