[英]VotingClassifier in sklearn.ensemble ImportError
I am trying to implement multiple learning classifiers in python.我正在尝试在 python 中实现多个学习分类器。 I have 5 random forest classifiers in the code but now I am not able to import the
VotingClassifier
function from sklearn.ensemble
.我在代码中有 5 个随机森林分类器,但现在我无法从
sklearn.ensemble
导入VotingClassifier
函数。
When I write this:当我写这个:
from sklearn.ensemble import VotingClassifier
the error says:错误说:
ImportError: cannot import name VotingClassifier
How can I fix this?我怎样才能解决这个问题?
I am the person who implemented the VotingClassifier
in scikit-learn.我是在 scikit-learn 中实现
VotingClassifier
的人。 Sorry for the confusion, I just stumbled upon the "examples" section in the scikit-learn 16.1 documentation.抱歉造成混淆,我只是偶然发现了 scikit-learn 16.1 文档中的“示例”部分。 This is a little bit misleading, the
VotingClassifier
is already implemented but will be in the next version of scikit-learn 0.17.这有点误导,
VotingClassifier
器已经实现,但将在 scikit-learn 0.17 的下一个版本中实现。
If you want to use it "already" you have 2 options:如果你想“已经”使用它,你有两个选择:
1) you could install the current scikit-learn dev version available via GitHub: https://github.com/scikit-learn/scikit-learn (instructions are in the Readme) 1) 您可以通过 GitHub 安装当前可用的 scikit-learn 开发版本: https : //github.com/scikit-learn/scikit-learn (说明在自述文件中)
2) alternatively, you could use it from mlxtend
as EnsembleClassifier
( http://rasbt.github.io/mlxtend/docs/classifier/scikit-learn_ensemble_classifier/ ) until the new scikit-version comes out. 2) 或者,您可以将
mlxtend
它用作EnsembleClassifier
( http://rasbt.github.io/mlxtend/docs/classifier/scikit-learn_ensemble_classifier/ ),直到新的 scikit-version 出现。 The mlxtend
package is a little "playground" of mine where I upload some examples and functions that I find useful at times. mlxtend
包是我的一个小“游乐场”,我上传了一些我觉得有时有用的示例和函数。
Hope that helps!希望有帮助!
Your issue is clear & solve-able.您的问题很明确且可以解决。 The devil hides in the detail.
魔鬼藏在细节中。
VotingClassifier
was announced in a scikit-learn changelog to be the add-on right for the still-wet-ink release of 0.17.0
. VotingClassifier
在 scikit-learn 更新日志中被宣布为0.17.0
仍然是湿墨水版本的0.17.0
。
If you are running Anaconda / conda
package-manager for python, check:如果您正在为 python 运行
Anaconda / conda
package-manager,请检查:
$ conda search —all scikit-learn
and $ conda search —all scikit-learn
和
$ conda depends scikit-learn
to verify any newly added dependencies $ conda depends scikit-learn
来验证任何新添加的依赖项
$ conda create -n (test-0-17-0-sklearn) scikit-learn
for creating a new, separate, conda
-named / -controlled environment for running python altogether with a sure sklearn ver. $ conda create -n (test-0-17-0-sklearn) scikit-learn
创建一个新的,独立的, conda
-named / -controlled与肯定sklearn版本完全运行Python环境。 0.17.0 for your further DEV/TEST 0.17.0 为您进一步的开发/测试
try:
{ ... } except:
{ ... } try:
{ ... } except:
{ ... }try:
from sklearn.ensemble import VotingClassifier
except:
try:
import sklearn
print "WARNING: [VotingClassifier] not available\n",
"WARNING: [import sklearn] reports version: ",
sklearn.__version__, "\n"+60*"|"
except:
print "WARNING: impossible to [import sklearn] at all\n",
60*"|"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.