What is the meaning of best_score_ of GridSearchCV, when using custom error function?
I'm running a simple experiment with Scikit GridSearchCV.
1) Train simple 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 results:
print lin_svm_grid.best_score_
print mean_squared_error(y, lin_svm_grid.best_estimator_.predict(x))
-610.141599985
236.578850489
So here is the main trouble: why the values are different? I guess GridSearchCV score is R^2 score, and can i make GridSearchCV return error function value instead of R^2?