Skip to content

DEP expose y_score instead of y_pred RocCurveDisplay.from_predictions #29865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 12, 2025

Conversation

bagustris
Copy link
Contributor

@bagustris bagustris commented Sep 17, 2024

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
Copy link

github-actions bot commented Sep 17, 2024

✔️ 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
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
Contributor 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
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
Contributor Author

@glemaitre

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

Copy link
Member

@jeremiedbb jeremiedbb left a comment

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

<...>
>>> plt.show()
"""
# 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
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.

Copy link
Contributor Author

@bagustris bagustris Oct 11, 2024

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
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
Contributor Author

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

@glemaitre
Copy link
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
Copy link
Member

@glemaitre glemaitre left a comment

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.

Copy link
Member

@jeremiedbb jeremiedbb left a comment

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
30 of 33 checks passed
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
None yet
Development

Successfully merging this pull request may close these issues.

Misleading variable name for the example of AUC calculation
3 participants