Because we need to call the AdaBoost algorithm in the Scikit package, we need to set up a basic classifier, because we don't know how to set some classifiers at the beginning, error message:
Typeerror:fit () got an unexpected keyword argument ' sample_weight ' and then searched the web for someone to ask the following question:
I am trying to use adaboostclassifier with a base learner other than DecisionTree. I have the tried SVM and kneighborsclassifier but I get errors. Can some one point out of the classifiers that can is used with Adaboostclassifier?
Ok, we have a systematic method to find out all of the base learners supported by Adaboostclassifier. Compatible base Learner ' s fit method needs to support Sample_weight, which can is obtained by running following code:
Import inspectfrom sklearn.utils.testing Import all_estimatorsfor name, CLF in all_estimators (type_filter= ' classifier ' ): if ' sample_weight ' in Inspect.getargspec (CLF (). Fit) [0]: print Name
This results in following output:adaboostclassifier, Bernoullinb, Decisiontreeclassifier, Extratreeclassifier, Extratreesclassifier, MULTINOMIALNB, Nusvc, Perceptron, Randomforestclassifier, RIDGECLASSIFIERCV, SGDClassifier, SVC .
Run results
If the classifier doesn ' t implement Predict_proba, you'll have a to set adaboostclassifier parameter algorithm = ' Samme '.
Original link: http://stackoverflow.com/questions/18306416/adaboostclassifier-with-different-base-learners
Scikit the problem that the package encountered.