1. XG Boost
Contents
(클릭시 해당 주제로 이동)
1. Gradient Boosting이란?
먼저 Boosting의 기본적인 아이디어는 Weak learner(약한 분류기)들의 조합으로
하나의 모델을 만드는 것이 하나의 Strong leaner(강한 분류기)의 모델보다
더 강력하다는 것에 있다.
Gradient Boosting은 예측모델에서 강력한 성능을 보여주는 모델 중 하나이다.
XG Boost, Light GBM. CatBoost들은 이러한 Gradient Boosting Algorithm을 구현한 패키지이다.
*Gradient Boosting Algorithm의 3가지 요소
1. Loss Function Optimized
ex) cross-entropy for classification mean squad Error for regression
2. Weak Learned to make Predictions
ex) Greedly constructed decision-tree
3. Additive Model
2. XG Boost(eXtreme Gradient Boosting)
Gradient Boosted 기반 Speed/Performance 향상.
캐글(Kaggle)에서 XGBoost는 우수한 성적을 보여주며, 많은 사람들은 XGBoost를 기본 모델로 시작한다.
이전의 Gradoent Boosting은 sequential(순차적으로) 트리를 추가하며
모델을 만들었기 때문에 느렸다. (XGBoost는 이 문제를 해결)
*특징
1. Cache Optimization
2. Out of core computing for large data sets that do not fit memory
3. Parallelization; Use all CPU cores
4. Distributed Computing : Large models use clusters.
3. XG Boost 시작하기.
{ }
4. Early Stopping
XG Boost는 모델은 training하는 동안에, evaluate 할 수 있다. (Verbose=True)
ex)
eval_set=[(x-test, y_test)]
model_fit(x_train, y_train, eval_metric="error", eval_set=eval_set,
verbose=True
이러한 evaluation을 토대로, model이 Impwvement하지 않으면, training을 멈출수 있다.
(Early Stopping)
ex)
{ }
5. Feature Importance
-Print (model.feature-importances_)
-plot_importance(model); Built-in function to plot features ordered by Importance pyplot.show
{ }
-feature Importance code example
{ }
6. Configure
1. Learning_rate : Should be I.I or lower, 작은 값 → 추가의 트리들이 필요.
2. tree_depth : 보통 2~8. deeper tree → not much benefit.
3. Subsample : Row sampling; 보통 30%~80%(of the training set)
100% → No sampling.
*Configuration 전략
1. Default configuration 돌려 본 후, train/validate set에서 plot을 사용해서 learning curve를 확인한다.
2. Overlearning → learning rate 감소 or 트리 갯수가 증가
3. Under learning → learning rate 증가 or 트리 갯수가 감소
*Suggestion
set # of tree 100 or 1000 then tune the learning rate → quickly find a good model
7. hyperparameter Tuning
-Scikit-learn의 Grid search CV사용하여 hyperparameter 튜닝가능.
For Grid search
{ }
-중요한 Parameters
* The number/size of trees; n-estimators/max_depth
* The learning rate : learning_rate
* Row/column subsampling rates: subsample/colsample_by tree/colsample_byeve
ex)
{ }
'Articles' 카테고리의 다른 글
[Articles] 클러스터링 알고리즘들 (Unsupervised Learning이란?) (0) | 2020.02.09 |
---|---|
Git 사용하기 (0) | 2020.01.13 |
머신러닝 기초 (0) | 2020.01.05 |
3. Ensemble (0) | 2019.12.28 |
2. Statistical Methods (0) | 2019.12.27 |
댓글