Tham số bagging: mẹo và thủ thuật

Ensemble Methods in Python

Román de las Heras

Data Scientist, Appodeal

Tham số cơ bản cho bagging

Tham số cơ bản
  • base_estimator
  • n_estimators
  • oob_score
    • est_bag.oob_score_
Ensemble Methods in Python

Tham số bổ sung cho bagging

Tham số bổ sung
  • max_samples: số mẫu lấy cho mỗi estimator.
  • max_features: số đặc trưng lấy cho mỗi estimator.
    • Phân loại ~ sqrt(số_đặc_trưng)
    • Hồi quy ~ số_đặc_trưng / 3
  • bootstrap: có lấy mẫu hoàn lại hay không.
    • True --> max_samples = 1.0
    • False --> max_samples < 1.0
Ensemble Methods in Python

Rừng ngẫu nhiên

Phân loại

from sklearn.ensemble import RandomForestClassifier

clf_rf = RandomForestClassifier(
    # parameters...
)

Hồi quy

from sklearn.ensemble import RandomForestRegressor

reg_rf = RandomForestRegressor(
    # parameters...
)

Tham số bagging:

  • n_estimators
  • max_features
  • oob_score

Tham số riêng của cây:

  • max_depth
  • min_samples_split
  • min_samples_leaf
  • class_weight ("balanced")
Ensemble Methods in Python

Đánh đổi độ chệch–phương sai

Độ chệch–phương sai.png

Ensemble Methods in Python

Ayo berlatih!

Ensemble Methods in Python

Preparing Video For Download...