Search code examples
machine-learningscikit-learnadaboostensemble-learning

How to see the prediction of each base estimator of adaboost classifier in sklearn ensamble


i can see the prediction using AdaBoostClassifier of ensemble method of sklearn using code like this.

from sklearn.ensemble import AdaBoostClassifier
clf = AdaBoostClassifier(n_estimators=100)
clf.fit(X_train, y_train)
y_pred= clf.predict(X_test)
print y_pred

Now i want to see the prediction of all base estimators(i.e. estimation of all the individual 100 base estimators.) Is it possible in sklearn. How would i do that ?please help me. Thnaks in advance.


Solution

  • for estimator in clf.estimators_:
        print estimator.predict(X_test)
    

    You can also get weight and classification error for each estimator, see documentation.