8000 ENH RocCurveDisplay add option to plot chance level by Charlie-XIAO · Pull Request #25987 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

ENH RocCurveDisplay add option to plot chance level #25987

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 27 commits into from
Mar 30, 2023

Conversation

Charlie-XIAO
Copy link
Contributor
@Charlie-XIAO Charlie-XIAO commented Mar 27, 2023

Reference Issues/PRs

towards #25929. Relevant PR: #25972.

What does this implement/fix? Explain your changes.

This PR implements the following:

  • Add attribute chance_level_ to RocCurveDisplay class
  • Add option to plot the chance level line, and supports passing a dict to alter its style
  • Will not plot the chance level line multiple times
  • Update examples where RocCurveDisplay is used. Remove the part we were plotting the chance level by hand and instead use the new feature.

Any other comments?

The previous pull request is #25972, but it was from another repo so reviewers do not have permission to directly modify it. Therefore I closed that issue and moved the changes here, meanwhile adopting the suggestions by @glemaitre.

@Charlie-XIAO
Copy link
Contributor Author

In the current implementation, I searched the all the lines of ax_ to check if the chance level line is already plotted. That is really inefficient. For instance, if one plots n times in a for loop, the complexity would be 1+...+n=O(n^2). I haven't figured out a better way to do this. Please let me know if I need to change the implementation.

@glemaitre
Copy link
Member

In the current implementation, I searched the all the lines of ax_ to check if the chance level line is already plotted. That is really inefficient. For instance, if one plots n times in a for loop, the complexity would be 1+...+n=O(n^2). I haven't figured out a better way to do this. Please let me know if I need to change the implementation.

We should not try to be smart. We just need to add the capability. Being False by default means that we will not plot the chance level t 8000 wice. People will be able to use the feature if they read the documentation. This is good enough.

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.

Another quick review.

@glemaitre glemaitre self-requested a review March 28, 2023 14:35
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.

After checking the rendering, I have the following changes to propose.