我想对我的数据应用一种集成方法,多数投票。我还通过“pip install mlxtend”安装了“mlxtend”。我仍然得到错误。下面是我得到的错误。在
首先是代码:
from mlxtend.classifier import EnsembleVoteClassifier
mv_clf = MajorityVoteClassifier(classifiers=[pipe1, clf2, pipe3])
clf_labels += ['Majority Voting']
all_clf = [pipe1, clf2, pipe3, mv_clf]
for clf, label in zip(all_clf, clf_labels):
scores = cross_val_score(estimator=clf,
X=X_train,
y=y_train,
cv=10,
scoring='roc_auc')
print("Accuracy: %0.2f (+/- %0.2f) [%s]"% (scores.mean(), scores.std(), label))
注意我之前定义了clf1,clf2和clf3,那部分完全是精细的。在
错误如下:
^{pr2}$ImportError:没有名为exceptions的模块
更新:更新scikit学习版本后,我得到的错误是
NameError Traceback (most recent call last)
<ipython-input-16-9643a2b164d6> in <module>()
1 from mlxtend.classifier import EnsembleVoteClassifier
2 from sklearn.ensemble import RandomForestClassifier, VotingClassifier
----> 3 mv_clf = MajorityVoteClassifier(classifiers=[pipe1, clf2, pipe3])
4
5
NameError: name 'MajorityVoteClassifier' is not defined
sklearn.exceptions
模块是sklearn
的introduced in version 0.18.0。您只需将安装升级到最新版本(撰写本文时为0.18.1):如果您通过via Anaconda安装,请使用:
^{pr2}$这将解决问题并允许您使用
sklearn.exceptions
模块。在相关问题 更多 >
编程相关推荐