Skip to content

DEP expose y_score instead of y_pred RocCurveDisplay.from_predictions#29865

Merged
jeremiedbb merged 17 commits into
scikit-learn:mainfrom
bagustris:fix-roccurverdisplay-args-docs
Apr 12, 2025
Merged

DEP expose y_score instead of y_pred RocCurveDisplay.from_predictions#29865
jeremiedbb merged 17 commits into
scikit-learn:mainfrom
bagustris:fix-roccurverdisplay-args-docs

Conversation

@bagustris

@bagustris bagustris commented Sep 17, 2024

Copy link
Copy Markdown

Reference Issues/PRs

Fix #29823

What does this implement/fix? Explain your changes.

  • Changes y to t_true and y_pred to y_score in AUC docs.
  • Changes args y_pred to y_score in RocCurveDisplay.from_predictions (along with a warning for depreciation)

Could you check @jeremiedbb @glemaitre?

@bagustris bagustris changed the title REFAC update ROC curve plotting to use y_score instead of y_pred; dep… REFAC update ROC curve plotting to use y_score instead of y_pred Sep 17, 2024
@github-actions

github-actions Bot commented Sep 17, 2024

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 4435e09. Link to the linter CI: here

@glemaitre glemaitre self-requested a review September 17, 2024 15:52
@glemaitre

Copy link
Copy Markdown
Member

@bagustris Could you solve the issue with the linter. It looks like you did not reformat with the right tool. You should have only a minimum diff (here you modified aorund 50 files).

Once this is solve, I'll make a review. Also, you will need for sure to add an entry in the changelog under the whats_new/v1.6.rst.

@bagustris

Copy link
Copy Markdown
Author

@glemaitre
Perhaps it is now ready for review.

I only edited two files, as shown in first commit d098d12, then run black and ruff; maybe other changes come from them (or my vscode settings?)

@bagustris bagustris marked this pull request as ready for review September 18, 2024 02:42
@glemaitre

Copy link
Copy Markdown
Member

I still see 64 file changed. Could you revert and avoid any reformatting apart from your changes.

@bagustris bagustris force-pushed the fix-roccurverdisplay-args-docs branch from c67cbfa to cb28366 Compare September 20, 2024 02:18
@bagustris

Copy link
Copy Markdown
Author

@glemaitre

Done to revert to first commit and then update as needed.

@jeremiedbb jeremiedbb left a comment

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.

Thanks for the PR @bagustris, here are a few comments

Comment thread doc/whats_new/v1.6.rst Outdated
Comment thread sklearn/metrics/_ranking.py Outdated
Comment thread sklearn/metrics/_plot/roc_curve.py
Comment thread sklearn/metrics/_plot/roc_curve.py Outdated
"""
# TODO(1.8): Remove y_pred support and use y_score only
if y_score is not None and not isinstance(y_pred, str):
raise ValueError(

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.

We need to had new tests to be sure that we properly raise this error.
Basically this is the same thing for the code non-covered in the line below.

@bagustris bagustris Oct 11, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added unit tests namely test_y_score_and_y_pred_deprecation and test_y_pred_deprecation_warning in test_roc_curve_display.py. I also changed y_pred to y_score in that test file following the proposed changes in this PR.

@glemaitre glemaitre self-requested a review October 11, 2024 15:52
y_pred = np.array([0.1, 0.4, 0.35, 0.8])

with pytest.warns(FutureWarning, match="y_pred was deprecated in version 1.6"):
display = RocCurveDisplay.from_predictions(y_true, y_pred=y_pred)

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.

The fact that this test is failing with because we are missing y_score means that we have a regression.

@jeremiedbb Do you see a way to get around this issue.
Indeed, I was thinking that you could move the * such that y_score is a keyword only argument as well. However, then we need to define a default for it and thus deprecate it and remove it later.

At least this is the only way that I'm seeing this change possible. And if this is the case, I would be pragmactic and not go with all this hassle for both our users (when checking the documentation) and ourself (to make the maintenance).

Anyt thoughts?

@bagustris

Copy link
Copy Markdown
Author

@jeremiedbb @glemaitre let me know if further work is needed.

@glemaitre

Copy link
Copy Markdown
Member

Let me solve the conflict and provide another round of review.

@glemaitre glemaitre self-requested a review January 2, 2025 10:46
@glemaitre glemaitre changed the title REFAC update ROC curve plotting to use y_score instead of y_pred DEP expose y_score instead of y_pred RocCurveDisplay.from_predictions Jan 2, 2025

@glemaitre glemaitre left a comment

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.

I resolved the commit and modify a couple of things:

  • add the changelog fragment
  • add a default for y_score (i.e. y_score=None) option for backward compatibility
  • update the deprecation version

LGTM on my side. @jeremiedbb maybe you want to have another look.

@jeremiedbb jeremiedbb left a comment

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.

LGTM. The CI failure is unrelated. Thanks @bagustris

@jeremiedbb jeremiedbb merged commit a744c47 into scikit-learn:main Apr 12, 2025
lucyleeow pushed a commit to EmilyXinyi/scikit-learn that referenced this pull request Apr 23, 2025
…scikit-learn#29865)

Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Co-authored-by: Jérémie du Boisberranger <jeremie@probabl.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

Misleading variable name for the example of AUC calculation

4 participants