Adaboost在sklearn Python中的估计错误

huangapple go评论77阅读模式
英文:

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:

Adaboost在sklearn Python中的估计错误

I have few questions:

  1. is it the errors for the test set or train set?
  2. why in 30 the error is 1?
  3. 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:

Adaboost在sklearn Python中的估计错误

I have few questions:

  1. is it the errors for the test set or train set?
  2. why in 30 the error is 1?
  3. 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.

huangapple
  • 本文由 发表于 2020年1月6日 17:46:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/59609823.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定