July 2017
Intermediate to advanced
382 pages
9h 13m
English
In scikit-learn, AdaBoost is just another ensemble estimator. We can create an ensemble from 100 decision stumps as follows:
In [6]: from sklearn.ensemble import AdaBoostClassifier... ada = AdaBoostClassifier(n_estimators=100,... random_state=456)
We can load the breast cancer set once more and split it 75-25:
In [7]: from sklearn.datasets import load_breast_cancer... cancer = load_breast_cancer()... X = cancer.data... y = cancer.targetIn [8]: from sklearn.model_selection import train_test_split... X_train, X_test, y_train, y_test = train_test_split(... X, y, random_state=456... )
Then fit and score AdaBoost using the familiar procedure:
In [9]: ada.fit(X_train, y_train)... ada.score(X_test, y_test) ...
Read now
Unlock full access