scikit包遇到的问题。
来源:互联网 发布:阳西县官方网络问政 编辑:程序博客网 时间:2024/05/19 17:06
因为需要调用scikit包中Adaboost算法,我们需要设定一个基础分类器,因为开始不知道随便设定一些分类器,出现错误信息:
TypeError: fit() got an unexpected keyword argument 'sample_weight' 然后网上搜到有人问到这个问题如下:
I am trying to use AdaBoostClassifier with a base learner other than DecisionTree. I have tried SVM and KNeighborsClassifier but I get errors. Can some one point out the classifiers that can be used with AdaBoostClassifier?
Ok, we have a systematic method to find out all the base learners supported by AdaBoostClassifier. Compatible base learner's fit method needs to support sample_weight, which can be 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.
运行结果如图:
If the classifier doesn't implement predict_proba, you will have to set AdaBoostClassifier parameter algorithm = 'SAMME'.
原始链接:http://stackoverflow.com/questions/18306416/adaboostclassifier-with-different-base-learners- scikit包遇到的问题。
- 这两天遇到的scikit-learn的问题
- 安装scikit-learn及可能遇到的问题
- Python机器学习包scikit-learn安装步骤,包含了各种可能遇到的错误!!!
- scikit-image包的安装
- python安装scikit-learn遇到问题汇总
- 打jar包遇到的问题
- SSH整合---遇到的包冲突问题
- wireshark抓包遇到的问题
- phonegap运行www包遇到的问题
- 安装MYSQL-PYTHON包遇到的问题
- 打AD-Hoc包遇到的问题
- Android 打签名包遇到的问题
- Rstudio安装包遇到的问题
- 项目打war包遇到的问题
- 遇到一个闭包的问题~
- Python import各种包遇到的问题
- INSTALL_PARSE_FAIL_NO_CERTIFICATE 打jar包的时候遇到的问题。
- OpenCV源码解析之CascadeClassifier多尺度检测
- Hadoop进阶之输入路径如何正则通配?
- [LeetCode] Valid Parentheses
- AFNetworking 2.0 网络请求封装使用
- NY86 找球号(一)【二分查找】
- scikit包遇到的问题。
- 第21题
- android保存图片到SD卡并以时间命名
- Markdown基本符号快捷键
- spring read-only理解
- Pthread的配置 win32情况和x64
- 输入n个整数,输出其中最小的k个
- 第七周项目1-图形用户界面(GUI)应用程序开发初体验
- Java并发性和多线程介绍目录