The reason is due to some historical choices in the design of the GridSearchCV
and RandomizedSearchCV
by scikit-learn developers.
These SearchCV
will select the set of hyperparameters that maximizes a given score. An error is something that is in the range [0, inf)
. Therefore, using it instead of a score in a SearchCV
, one would need to minimize it.
Instead of switching minimization and maximization depending if we use an error or a score, the SearchCV
always request a score (a higher value means a better model). Therefore, a choice was made to take the negative error that would range from (-inf, 0]
that can therefore be maximized.