【发布时间】:2014-07-28 13:39:12
【问题描述】:
我一直试图弄清楚 GridSearchCV 的 best_score_ 参数是如何计算的(或者换句话说,它是什么意思)。 documentation 说:
在遗漏数据上的 best_estimator 得分。
所以,我试着把它翻译成我理解的东西,并计算了实际“y”的 r2_score 和每个 kfold 的预测 y - 并得到了不同的结果(使用这段代码):
test_pred = np.zeros(y.shape) * np.nan
for train_ind, test_ind in kfold:
clf.best_estimator_.fit(X[train_ind, :], y[train_ind])
test_pred[test_ind] = clf.best_estimator_.predict(X[test_ind])
r2_test = r2_score(y, test_pred)
我到处寻找对 best_score_ 更有意义的解释,但找不到任何东西。有人愿意解释一下吗?
谢谢
【问题讨论】:
-
通常是折叠的平均值。但是,如果您可以发布完整的代码,那就太好了,例如模拟数据。
标签: python python-2.7 machine-learning scikit-learn