英文:
Estimator errors in Adaboost sklearn python
问题
I was implementing sklearn AdaBoostClassifier and I plotted the estimator_errors_ which said is the classification error for each estimator in the boosted ensemble.
This is the plot:
I have few questions:
- is it the errors for the test set or train set?
- why in 30 the error is 1?
- is it accumulated error?
Thank you.
my code:
base = LinearSVC(tol=1e-10, loss='hinge', C=1000, max_iter=50000)
ada = AdaBoostClassifier(base_estimator=base, algorithm='SAMME', n_estimators=n, random_state=10)
英文:
I was implementing sklearn AdaBoostClassifier and I plotted the estimator_errors_ which said is the classification error for each estimator in the boosted ensemble.
This is the plot:
I have few questions:
- is it the errors for the test set or train set?
- why in 30 the error is 1?
- is it accumulated error?
Thank you.
my code:
base = LinearSVC(tol=1e-10, loss='hinge', C=1000, max_iter=50000)
ada = AdaBoostClassifier(base_estimator=base ,algorithm='SAMME', n_estimators=n,random_state=10)
答案1
得分: 3
Sklearn的AdaBoostClassifier默认参数为n_estimators=50,我认为这在你的情况下被使用。然而,如果达到其他条件之一,增强过程可能会提前终止。这可能由基本估计器或SAMME算法的停止条件之一所决定。
根据您的情况,根据图表,看起来在30个估计器后增强停止。您可以轻松地通过以下方式获取实际的估计器数量:
len(estimator)
其中estimator是使用AdaBoostClassifier拟合的估计器。错误的类型取决于在打印“estimator_errors_”之前执行的函数。
estimator.predict(X_test)
estimator.estimator_errors_
显示了测试数据“X_test”的错误。
希望这有所帮助。
英文:
Sklearn AdaBoostClassifier has a default parameter for n_estimators=50 which I believe is used in your case. However, the boosting process may terminate early if one of the other conditions is reached. This maybe dictated by one of the stopping conditions for the base estimator or the SAMME algorithm.
In your case based on the plot, it seems like the boosting stops after 30 estimators. You can easily obtain the actual number of estimators using,
len(estimator)
where estimator is the fitted estimator using AdaBoostClassifier. The type of error depends on the function performed before printing estimator_errors_
.
estimator.predict(X_test)
estimator.estimator_errors_
shows error for the test data X_test
.
hope that helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论