如何解决ImportError:没有命名为exceptions的模块

2024-09-30 01:31:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我想对我的数据应用一种集成方法,多数投票。我还通过“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

Tags: fromimportlabels错误clfclassifiersclassifiermv

热门问题