Skip to content

sklearn/make-scorer-loss-direction

Pack Severity Fix Versions
scikit-learn warning none, edit by hand All versions

sklearn.metrics.make_scorer defaults to greater_is_better=True. Wrapping a loss or error function without greater_is_better=False causes GridSearchCV and RandomizedSearchCV to maximize the loss and pick the worst hyperparameters (on an asymmetric penalty, omitting greater_is_better=False picked alpha=10000.0 with loss 6.251 instead of alpha=1.0 with loss 1.204).

scorer = make_scorer(asymmetric_loss)
scorer = make_scorer(asymmetric_loss, greater_is_better=False)

Calls to make_scorer wrapping a scikit-learn, Nixtla, or custom *_loss / *_error / *_deviance function without an explicit greater_is_better= argument.

Pass greater_is_better=False for losses and errors (or greater_is_better=True explicitly if the wrapped function already returns a negated utility).

make_scorer defaults to greater_is_better=True, so GridSearchCV and cross-validation maximize a loss or error function and select the worst parameters. Pass greater_is_better=False for loss and error functions.

See all rules in the scikit-learn pack.