Skip to content
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

FEA Add positive and negative likelihood ratios to metrics #22518

Merged
merged 83 commits into from May 17, 2022

Conversation

ArturoAmorQ
Copy link
Member

Reference Issues/PRs

Fixes #22404.

What does this implement/fix? Explain your changes.

We agreed that we should add positive and negative likelihood ratios as they are considered as standard good practice in medicine / public health, as well as interpretable in terms of the pre-test versus post-test odds ratio even in class imbalance.

Any other comments?

This is a first PR that creates a broad function that computes both positive and negative likelihood ratios. A second step of creating functions that specifically select one or the other ("positive_likelihood_ratio" and a "negative_likelihood_ratio") will be addressed in another PR once that we agreed on forms and variable names for this one.

@ArturoAmorQ ArturoAmorQ changed the title [WIP] Add positive and negative likelihood ratios to metrics Add positive and negative likelihood ratios to metrics Feb 21, 2022
@jjerphan jjerphan self-requested a review Feb 25, 2022
@jjerphan jjerphan changed the title Add positive and negative likelihood ratios to metrics FEA Add positive and negative likelihood ratios to metrics Feb 25, 2022
doc/whats_new/v1.1.rst Outdated Show resolved Hide resolved
Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

Here is a first pass with various comments.

sklearn/metrics/tests/test_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/tests/test_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
sklearn/metrics/_classification.py Outdated Show resolved Hide resolved
doc/whats_new/v1.1.rst Outdated Show resolved Hide resolved
@ArturoAmorQ
Copy link
Member Author

ArturoAmorQ commented May 6, 2022

I actually had in mind to remove the part showing how the classifier boundary is shifted by class imbalance.

The example shows how the decision boundary is kept constant across different prevalences. I thought the illustration was required as this is indeed not the most intuitive user case.

I do think that the two examples could be cross-linked

Good idea, it's done :)

ArturoAmorQ and others added 2 commits May 6, 2022
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Copy link
Member

@GaelVaroquaux GaelVaroquaux left a comment

Choose a reason for hiding this comment

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

LGTM. One minor suggestion

examples/model_selection/plot_likelihood_ratios.py Outdated Show resolved Hide resolved
ArturoAmorQ and others added 6 commits May 10, 2022
@GaelVaroquaux
Copy link
Member

It seems that you still have a conflict :(

@glemaitre glemaitre self-requested a review May 13, 2022
ArturoAmorQ and others added 4 commits May 13, 2022
@glemaitre glemaitre merged commit 9d48197 into scikit-learn:main May 17, 2022
29 of 30 checks passed
Copy link
Contributor

@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.

Thanks @ArturoAmorQ LGTM. Merging.

@ArturoAmorQ
Copy link
Member Author

Thanks @jjerphan, @GaelVaroquaux, @glemaitre and @ogrisel for your time and the fruitful discussions we had online and on real life. It was really fun to implement this feature!

@GaelVaroquaux
Copy link
Member

GaelVaroquaux commented May 17, 2022 via email

lesteve pushed a commit to lesteve/scikit-learn that referenced this pull request May 19, 2022
…arn#22518)

Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
@ArturoAmorQ ArturoAmorQ deleted the likelihood_ratios branch May 20, 2022
mathijs02 pushed a commit to mathijs02/scikit-learn that referenced this pull request Dec 27, 2022
…arn#22518)

Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add Positive Likelihood Ratio (and negative) to metrics
5 participants