Skip to content

MNT remove default behaviour deprecation from class_likelihood_ratios #31331

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

Conversation

StefanieSenger
Copy link
Contributor

@StefanieSenger StefanieSenger commented May 7, 2025

Reference Issues/PRs

towards #29048
(It's a partial reversal of #29288.)

What does this implement/fix? Explain your changes.

This removes the deprecation of the default behaviour in case of a zero division from class_likelihood_ratios.

The default behaviour in case of a division by zero was np.nan before, as (indirectly) defined by raise_warning=True, which was the default before..

CC @adrinjalali, @jeremiedbb, @virchan

@StefanieSenger StefanieSenger added this to the 1.7 milestone May 7, 2025
Copy link

github-actions bot commented May 7, 2025

✔️ Linting Passed

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

Generated for commit: c1f7e9e. Link to the linter CI: here

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

@@ -2220,28 +2213,11 @@ class are present in `y_true`): both likelihood ratios are undefined.
"`UndefinedMetricWarning` will always be raised in case of a division by zero "
"and the value set with the `replace_undefined_by` param will be returned."
Copy link
Member

Choose a reason for hiding this comment

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

We also talked about expanding this error message to include a hint on how to handle this with catch_warnings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I've expanded the UndefinedMetricWarning messages to mention warnings.catch_warnings().

@adrinjalali
Copy link
Member

There's probably also a changelog for the old PR which we need to fix?

@StefanieSenger
Copy link
Contributor Author

StefanieSenger commented May 7, 2025

Thanks, @adrinjalali.
I've enhanced the warning messages. The changelog doesn't need to change, since the changelog additions made in #29288 didn't touch on the to be changed default value.

@jeremiedbb
Copy link
Member

The changelog doesn't need to change

I think that #29288 is missing a changelog entry for the deprecation of raise_warning. Can you add it in this PR please so that everything is clean ?

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.

(I added the missing changelog entry)
LGTM. Thanks @StefanieSenger

@jeremiedbb jeremiedbb merged commit a69849a into scikit-learn:main May 7, 2025
36 checks passed
@StefanieSenger
Copy link
Contributor Author

Thank you, @jeremiedbb!

@StefanieSenger StefanieSenger deleted the class_likelihood_ratios_stop_deprecation branch May 8, 2025 05:22
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