[AI]/Machine Learning(13)
-
Tree Based Model(2) - Random Forests
Learned Stuff Key Points Ensemble Model Random Forest Bagging Ordinal Encoder New Stuff [Ensemble Model] 여러개의 data set에 대한 각각의 model을 함께 사용해 기존보다 성능을 올리는 modeling 방법 Diagram [Random Forest] decision tree model의 Ensemble model라고 할 수 있습니다. 부가적으로 Bagging 방법으로 구현합니다. Diagram Bagging Bootstrapping + Aggregating Bootstrapping : data 를 sampling해서 하나의 subset으로 만드는 방법 Aggregating : 나눈 subset에서 만든 각각의 dec..
2021.03.07 -
Tree Based Model(3) - Evaluation Metrics for Classification
Learned Stuff Key Points Confusion Matrix Evaluation Metrics Accuracy Precision Recall ROC Curve & AUC Score New Stuff [Confusion Matrix] 만든 Model의 예측값과 실제값간의 관계를 보여주는 Matrix 형태의 그림이라고 볼 수 있습니다. True Positive : 예측 = 1 / 실제 = 1 True Negative : 예측 = 0 / 실제 = 0 False Positive : 예측 = 1 / 실제 = 0 (Type 1 Error) False Negative : 예측 = 0 / 실제 = 1 (Type 2 Error) Diagram Code from sklearn.metrics import pl..
2021.03.07 -
Tree Based Model(4) - Model Selection
Learned Stuff Key Points Cross-Validation Optimization & Generalization Randomized Search CV & Grid Search CV Target Encoder New Stuff [Cross-Validation] Hold-Out 교차 검증 : Train / Validation / Test data set 으로 나누는 방식 K-Fold CV : data를 K 만큼 쪼개서 한 부분 (validation 용)만 남겨놓고 나머지 부분 (train 용) 은 학습시키는 방식 시계열 data에는 적합하지 않음 data 갯수가 적을 때 유용 Diagram Code from sklearn.model_selection import cross_val_score ..
2021.03.07 -
Applied Predictive Modeling(1) - Choosing ML Problems
[Learned Stuff] Key Points Modeling Process Leakage Balancing Samples Log-Transform [New Stuff] [Modeling Process (Supervised Learning)] Target 분포 확인 Regression or Classification 문제로 보기 EDA / Data Preprocessing 진행 Baseline Model 만들기 Time Series : 당일 예측값 = 전일 Target 값 Regression : Target의 평균값 Classification : Target의 최빈값 Model 성능 비교 & Hyperparameter 최적화 Best Model 찾기 [Leakage] Model의 성능이 지나치게 좋게 ..
2021.03.07 -
Applied Predictive Modeling(2) - Data Wrangling
Learned Stuff Key Points Data Wrangling New Stuff [Data Wrangling] Data를 사용하기 쉽게 변형하거나 알아보기 쉽게 Mapping하는 방법 Steps Gather data를 얻는 과정 필요에 따라 여러 data를 수집할 수도 있음 Assess 얻은 data가 clean 한지 안한지 확인하는 단계 Clean define / code / test 로 나뉨 2 번 과정에서 발견한 문제점을 define 하고 code 로 clean을 한 뒤, 잘 clean 되었는지 test 하는 단계 Reassess & Iterate 추가적으로 clean 해야될 부분이 있다면 반복할 것 Store (optional) clean 한 data를 다시 사용하기 위해 저장하는 단계
2021.03.07 -
Applied Predictive Modeling(3) - (Feature, Permutation, Drop-Column) Importance & Boosting (Gradient Boosting)
Learned Stuff Key Points Feature Importance Permutation Importance Drop Column Importance Boosting Gradient Boosting (Regression & Classification) New Stuff [Feature Importance] 어떤 Feature가 Target을 예측하는데 큰 영향을 미치는지 확인해보는 여러 방법들 중 하나 Mean Decrease Impurity 를 계산한 값 1에 가까울수록 중요한 feature / 0에 가까울수록 덜 중요한 feature Feature Importance의 합은 1 Gini Impurity 복습 (Entropy 도 비슷한 개념) $Gini \ Index = 1-P(YES)^2-..
2021.03.07