Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (19k points)

I am trying to use AdaBoostClassifier with a base learner other than a decision tree. I have tried SVM and KNeighborsClassifier but I get errors. Can someone point out the classifiers that can be used with AdaBoostClassifier?

1 Answer

0 votes
by (33.1k points)

There is a way to find out all the base learners supported by AdaBoostClassifier. A compatible base learner's fit method needs to support sample_weight, which can be obtained by running following code:

import inspect

from sklearn.utils.testing import all_estimators

for name, clf in all_estimators(type_filter='classifier'):

    if 'sample_weight' in inspect.getargspec(clf().fit)[0]:

       print name

Output:

AdaBoostClassifier, BernoulliNB, DecisionTreeClassifier, ExtraTreeClassifier, ExtraTreesClassifier, MultinomialNB, NuSVC, Perceptron, RandomForestClassifier, RidgeClassifierCV, SGDClassifier, SVC.

If the classifier doesn't uses predict_proba, you will have to simply set AdaBoostClassifier parameter algorithm = 'SAMME'.

To learn more about Adaboost, go through Machine Learning Course. Also, visit Machine Learning Tutorial to master the course.

Hope this answer helps you!

Browse Categories

...