Skip to content

DOC Improve descriptions of roc_curve-related dosctrings #31238

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 6 commits into from
Apr 28, 2025

Conversation

ArturoAmorQ
Copy link
Member

Reference Issues/PRs

Follow-up from #29151.

What does this implement/fix? Explain your changes.

As suggested in #29151 (comment), this PR:

Any other comments?

I still feel that the whole description of the thresholds attribute in the roc_curve can be improved to avoid redundancies.

Copy link

github-actions bot commented Apr 22, 2025

✔️ Linting Passed

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

Generated for commit: 3b6e62a. Link to the linter CI: here

@@ -20,7 +20,7 @@ class RocCurveDisplay(_BinaryClassifierCurveDisplayMixin):
a :class:`~sklearn.metrics.RocCurveDisplay`. All parameters are
stored as attributes.

Read more in the :ref:`User Guide <visualizations>`.
Read more in the :ref:`User Guide <roc_metrics>`.
Copy link
Member

Choose a reason for hiding this comment

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

For ROCCurveDisplay, the visualizations link does show how to use the visualization api with ROCCurveDisplay: https://scikit-learn.org/stable/visualizations.html#visualizations

This kind of depends on what a reader wants to learn. "What is ROC Curve" or "How to use RocCurveDisplay"

Copy link
Member

Choose a reason for hiding this comment

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

We've resorted to linking both e.g.,

For general information regarding `scikit-learn` visualization tools, read
more in the :ref:`Visualization Guide <visualizations>`.
For details regarding interpreting these plots, refer to the
:ref:`Model Evaluation Guide <visualization_regression_evaluation>`.

Copy link
Member

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

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

This reads much better thanks!

Maybe we could consider linking both the visualization page and the metric page in the user guide?

@@ -1115,6 +1115,10 @@ def roc_curve(
fpr and tpr. `thresholds[0]` represents no instances being predicted
Copy link
Member

@lucyleeow lucyleeow Apr 28, 2025

Choose a reason for hiding this comment

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

I still feel that the whole description of the thresholds attribute in the roc_curve can be improved to avoid redundancies.

I think your description is clearer than this one. Why don't we use your wording here (and maybe make it explicit it is threshold[0]), then in the versionchanged we can just say something like: "The arbitrary threshold at infinity is added."

@ArturoAmorQ
Copy link
Member Author

@lucyleeow I slightly modified your suggestion in #31238 (comment), as the wording "For details" sounded as an understatement to me.

I also decided to keep everything related to the threshold at infinity inside the versionchanged directive, for consistency with det_curve:

.. versionchanged:: 1.7
An arbitrary threshold at infinity is added for the case `fpr=0`
and `fnr=1`.

but also to avoid repeating ourselves.

WDYT?

Copy link
Member

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

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

Thanks, this is much clearer! Some nits but LGTM!

@@ -1112,8 +1112,12 @@ def roc_curve(

thresholds : ndarray of shape (n_thresholds,)
Decreasing thresholds on the decision function used to compute
fpr and tpr. `thresholds[0]` represents no instances being predicted
and is arbitrarily set to `np.inf`.
fpr and tpr.
Copy link
Member

Choose a reason for hiding this comment

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

I think I prefer it being at least mentioned in the main description, but I am also okay with it the way it is now.

Co-authored-by: Lucy Liu <jliu176@gmail.com>
@thomasjpfan thomasjpfan merged commit 0173b91 into scikit-learn:main Apr 28, 2025
36 checks passed
@ArturoAmorQ ArturoAmorQ deleted the roc_curve_doctrings branch April 29, 2025 07:54
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.

3 participants