Bagging 參數:技巧與實務

Python 的 Ensemble 方法

Román de las Heras

Data Scientist, Appodeal

Bagging 的基本參數

基本參數
  • base_estimator
  • n_estimators
  • oob_score
    • est_bag.oob_score_
Python 的 Ensemble 方法

Bagging 的其他參數

其他參數
  • max_samples:每個估計器抽取的樣本數。
  • max_features:每個估計器抽取的特徵數。
    • 分類:約為 sqrt(number_of_features)
    • 迴歸:約為 number_of_features / 3
  • bootstrap:是否以放回方式抽樣。
    • True --> max_samples = 1.0
    • False --> max_samples < 1.0
Python 的 Ensemble 方法

隨機森林

分類

from sklearn.ensemble import RandomForestClassifier

clf_rf = RandomForestClassifier(
    # parameters...
)

迴歸

from sklearn.ensemble import RandomForestRegressor

reg_rf = RandomForestRegressor(
    # parameters...
)

Bagging 參數:

  • n_estimators
  • max_features
  • oob_score

樹模型參數:

  • max_depth
  • min_samples_split
  • min_samples_leaf
  • class_weight"balanced"
Python 的 Ensemble 方法

偏差—變異權衡

偏差與變異.png

Python 的 Ensemble 方法

一起來練習吧!

Python 的 Ensemble 方法

Preparing Video For Download...