Scikit the problem that the package encountered.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.