我有以下代码尝试使用设置为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']);