在python中的AdaBoostCassifier对象中循环n_estimators

我有以下代码尝试使用设置为3的n_estimators值循环遍历AdaboostClassifier对象,但为了得到每个n_estimators的图对,我无法使其t循环。 / p>

from sklearn.ensemble import AdaBoostClassifier
from sklearn.tree import DecisionTreeclassifier

ada = AdaBoostClassifier(DecisionTreeclassifier(max_depth=1),n_estimators=3,algorithm='SAMME',random_state=0).fit(X,y)
for stump in range(ada.estimators_):
    plt.subplot(1,2,1)
    plot_data(X,y)
    plot_predict(stump)
    plt.subplot(1,2)
    sklearn.tree.plot_tree(stump,filled=True,feature_names=['x1','x2']);
womenzhelihaiyouyu11 回答:在python中的AdaBoostCassifier对象中循环n_estimators

使用for stump in range(ada.n_estimators):代替for stump in range(ada.estimators_)

本文链接:https://www.f2er.com/1356182.html

大家都在问