多类随机森林的 OOB 分数图。 (一与休息)
OOB score graph for multiclass random forrest. (OneVsRest)
抱歉,我会懒洋洋地复制粘贴我的代码...我要解决的问题是为 3 class 问题绘制 OOB 错误图,(针对三个不同的 classifier) .类似于 http://scikit-learn.org/stable/auto_examples/ensemble/plot_ensemble_oob.html。
- 问题。
代码 returns,未定义有序字典的“标签”,即使我创建了它。在特定行上有评论。任何人都可以发现代码的问题???
min_estimators = 5
max_estimators = 250
estimator_list = estimator_01.estimators_ # List of estimators
labels_list = ['Binary OneVsRest estimator predicting agressiveness', 'Binary OneVsRest estimator predicting passiveness', 'Binary OneVsRest estimator predicting submissiveness'] #List of labels
estimators_dict = OrderedDict((label, []) for label, _ in zip(labels_list, estimator_list))
for i in range(min_estimators, max_estimators + 1):
for label, est in zip(labels_list, estimator_list):
estimator_01.set_params(estimator__n_estimators=i, estimator__oob_score=True, estimator__warm_start=True)
estimator_01.fit(x_train, y_train)
oob_error = 1 - est.oob_score_
estimators_dict[label].append((i, oob_error))
for label, clf_err in estimators_dict.items():
xs, ys = zip(*clf_err)
plt.plot(xs, ys, label=label)
plt.xlim(min_estimators, max_estimators)
plt.xlabel("n_estimators")
plt.ylabel("OOB error rate")
plt.title('Random Forrest classifier predicting pre-flop actions. OOB rate.')
plt.show()
MAXYMOO 回答了它。代码已相应更新。
- 问题
出于某种原因,它产生了三个单变量线,这在字面上是不可能的。任何想法为什么会这样?我附上图表。
你忘了在你的 for 循环中包含 label
,你需要这样:
for label, est in zip(label_list, estimator_list):
抱歉,我会懒洋洋地复制粘贴我的代码...我要解决的问题是为 3 class 问题绘制 OOB 错误图,(针对三个不同的 classifier) .类似于 http://scikit-learn.org/stable/auto_examples/ensemble/plot_ensemble_oob.html。
- 问题。
代码 returns,未定义有序字典的“标签”,即使我创建了它。在特定行上有评论。任何人都可以发现代码的问题???
min_estimators = 5
max_estimators = 250
estimator_list = estimator_01.estimators_ # List of estimators
labels_list = ['Binary OneVsRest estimator predicting agressiveness', 'Binary OneVsRest estimator predicting passiveness', 'Binary OneVsRest estimator predicting submissiveness'] #List of labels
estimators_dict = OrderedDict((label, []) for label, _ in zip(labels_list, estimator_list))
for i in range(min_estimators, max_estimators + 1):
for label, est in zip(labels_list, estimator_list):
estimator_01.set_params(estimator__n_estimators=i, estimator__oob_score=True, estimator__warm_start=True)
estimator_01.fit(x_train, y_train)
oob_error = 1 - est.oob_score_
estimators_dict[label].append((i, oob_error))
for label, clf_err in estimators_dict.items():
xs, ys = zip(*clf_err)
plt.plot(xs, ys, label=label)
plt.xlim(min_estimators, max_estimators)
plt.xlabel("n_estimators")
plt.ylabel("OOB error rate")
plt.title('Random Forrest classifier predicting pre-flop actions. OOB rate.')
plt.show()
MAXYMOO 回答了它。代码已相应更新。
- 问题
出于某种原因,它产生了三个单变量线,这在字面上是不可能的。任何想法为什么会这样?我附上图表。
你忘了在你的 for 循环中包含 label
,你需要这样:
for label, est in zip(label_list, estimator_list):