GridSearchCV得分与错误函数之间的差异

时间:2016-07-13 22:54:33

标签: python machine-learning scikit-learn cross-validation grid-search

使用自定义错误函数时,GridSearchCV的best_score_是什么意思?

我正在使用Scikit GridSearchCV进行简单的实验。

1)训练简单的svm:

from sklearn.svm import LinearSVR
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import mean_squared_error

lin_svm_grid_params = dict(svm__C = [0.01])
lin_svm = Pipeline([("scaler", StandardScaler()), ("svm", LinearSVR(dual=False, loss='squared_epsilon_insensitive'))]) 
lin_svm_grid = GridSearchCV(lin_svm, lin_svm_grid_params, cv = 10, scoring='mean_squared_error', n_jobs = -1)
lin_svm_grid.fit(x, y)

2)打印结果:

print lin_svm_grid.best_score_
print mean_squared_error(y, lin_svm_grid.best_estimator_.predict(x))
-610.141599985
236.578850489

所以这是主要的麻烦:为什么价值观不同?我猜GridSearchCV得分是R ^ 2得分,我可以使GridSearchCV返回错误函数值而不是R ^ 2吗?

0 个答案:

没有答案