Machine Learning met boomgebaseerde modellen in Python
Elie Kawerk
Data Scientist
Boosting: Ensemblemethode die meerdere zwakke leerders combineert tot één sterke.
Zwakke learner: Model dat net beter scoort dan gokken.
Voorbeeld van zwakke learner: Decision stump (CART met maximale diepte 1).
Train een ensemble van predictoren sequentieel.
Elke predictor corrigeert zijn voorganger.
Populairste boosting-methoden:
AdaBoost,
Gradient Boosting.
Staat voor Adaptive Boosting.
Elke predictor let meer op instanties die zijn voorganger fout had.
Dit doe je door gewichten van trainingsinstanties aan te passen.
Elke predictor krijgt een coëfficiënt $\alpha$.
$\alpha$ hangt af van de trainingfout.

Leersnelheid: $0 < \eta \leq 1$

Classificatie:
AdaBoostClassifier.Regressie:
AdaBoostRegressor.# Import models and utility functions
from sklearn.ensemble import AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split
# Set seed for reproducibility
SEED = 1
# Split data into 70% train and 30% test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3,
stratify=y,
random_state=SEED)
# Instantiate a classification-tree 'dt' dt = DecisionTreeClassifier(max_depth=1, random_state=SEED)# Instantiate an AdaBoost classifier 'adab_clf' adb_clf = AdaBoostClassifier(base_estimator=dt, n_estimators=100)# Fit 'adb_clf' to the training set adb_clf.fit(X_train, y_train) # Predict the test set probabilities of positive class y_pred_proba = adb_clf.predict_proba(X_test)[:,1]# Evaluate test-set roc_auc_score adb_clf_roc_auc_score = roc_auc_score(y_test, y_pred_proba)
# Print adb_clf_roc_auc_score
print('ROC AUC score: {:.2f}'.format(adb_clf_roc_auc_score))
ROC AUC score: 0.99
Machine Learning met boomgebaseerde modellen in Python