Skip to content

SLEP026: Deprecate and Remove score Method#101

Open
lorentzenchr wants to merge 1 commit into
scikit-learn:mainfrom
lorentzenchr:slep26
Open

SLEP026: Deprecate and Remove score Method#101
lorentzenchr wants to merge 1 commit into
scikit-learn:mainfrom
lorentzenchr:slep26

Conversation

@lorentzenchr
Copy link
Copy Markdown
Member

No description provided.

Comment thread slep026/proposal.rst
Comment on lines +264 to +265
>>> from sklearn.metrics import super_metric
>>> super_metric(y_true=y, y_pred=estimator.predict(X))
Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of the pain comes from having to know which form of predict a metric needs: (predict, predict_proba, or decision_boundary). For some metrics, you may need to slice predict_proba: est.predict_proba(X)[:, 1].

Two benefits of estimator.score(X, y, scoring="r2_score"):

  • Do not have to worry about the shape of the prediction.
  • If one is passing in scoring to a GridSearchCV(est, scoring="..."), they can run est.score(..., scoring="...") to see how the metrics behave before doing the full grid search. The API is a little more consistent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not have to worry about the shape of the prediction

If that’s the case, shouldn’t we fix those metrics/scores? Do you have an example?

I don’t understand you 2nd bullet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that’s the case, shouldn’t we fix those metrics/scores? Do you have an example?

An example is roc_auc_score, which can run with:

roc_auc_score(y_true, est.predict_proba(X)[:, 1])

or

roc_auc_score(y_true, est.decision_function(X))

Users need to understand the shape of the prediction to properly handle the metric. I guess the workaround is to:

scorer = get_scorer("roc_auc")
result = scorer(est, X, y)

For the grid search example, it's the same concern. I'm thinking of someone that is using GridSearchCV(..., scoring="roc_auc") and wonder "how do I manually compute the score?". If they use get_scorer, they they do not need to learn about the shape of the input to the underlying metric.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, get_scorer was also on my mind.
I guess we should just fix the roc_auc_score with predict_proba.

Comment thread slep026/proposal.rst

4.3. Downstream packages
------------------------
Many packages inherit from ``ClassifierMixin`` and ``RegressorMixin``, some examples include
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. We can go through a transition for scikit-learn estimators, but impacting third party estimators feels a bit more painful.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XGBoost overrides the score method, so no problem there.
LightGBM just inherits them. They would also inherit the deprecation and removal. They don’t need to do much if anything.

Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm mostly thinking about if LightGBM wants to keep score, they would need to implement it themselves. But they will find out that does not work anymore for first party scikit-learn meta-estimators.

There could also be third party meta-estimators (Like a SuperCustomSearchCV) that depend on .score, but also need to push users to pass in a scoring="some-metric-string".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants