Bagging 参数:技巧与建议

Python 中的集成方法

Román de las Heras

Data Scientist, Appodeal

Bagging 的基本参数

基本参数
  • base_estimator
  • n_estimators
  • oob_score
    • est_bag.oob_score_
Python 中的集成方法

Bagging 的其他参数

其他参数
  • max_samples:每个基学习器抽取的样本数。
  • max_features:每个基学习器抽取的特征数。
    • 分类 ~ sqrt(特征数)
    • 回归 ~ 特征数 / 3
  • bootstrap:是否有放回抽样。
    • True --> max_samples = 1.0
    • False --> max_samples < 1.0
Python 中的集成方法

随机森林

分类

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 中的集成方法

偏差-方差权衡

偏差-方差.png

Python 中的集成方法

让我们练习!

Python 中的集成方法

Preparing Video For Download...