1
$\begingroup$

I am using GridSearchCV to tune hyperparameters of regression decision tree. When I do, I get mean_test_score but I thought it would return mean MSE since it is a regressor. how to interpret mean_test_score? Is there a way to tweak GridSearchCV so it returns mean MSE?

here is my code

tree_reg = GridSearchCV(DecisionTreeRegressor(criterion="mse"), {
    "min_samples_split":[2,3,4],
    "min_samples_leaf":[1,2,3]
}, cv=5, return_train_score=False)

tree_reg.fit(X, y)

pd.DataFrame(tree_reg.cv_results_)
>>> params                   split0_test_score  .... mean_test_score
   {"min_samples_leaf":2,        0.998782             0.9989933
    "min_samples_split":3}

   {"min_samples_leaf":2,        0.998823             0.998930
    "min_samples_split":4}
            ...

what does mean_test_score mean?

$\endgroup$

1 Answer 1

3
$\begingroup$

By default, GridSearchCV uses the score method of its estimator; see the last paragraph of the scoring parameter on the docs:

If None, the estimator’s score method is used.

And DecisionTreeRegressor.score (indeed, all/most regressors) uses R^2.


In response to your edit: you can specify scoring='neg_mean_squared_error'. But note too that there's a linear relationship between MSE and R^2, so optimizing either of these are equivalent.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.