Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix default value of average in precision_recall_fscore_support #31270

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
Loading
from

Conversation

Foundsheep
Copy link

Reference Issues/PRs

None. This is a very trivial issue

What does this implement/fix? Explain your changes.

precision_recall_fscore_support has a parameter called average, and it is documented to be binary by default. However, it is actually coded to be None, and this mismatch causes an unexpected behaviour.

Any other comments?

The original aim might be the opposite to this commit, leaving it as it was(None), and changing the documentation. However, the fact that the original documentation explicitly mentions 'binary' for that value led me to make this decision

The original aim might be the opposite to this commit, leaving it as it was(None), and changing the documentation.
However, the fact that the original documentation explicitly mentions 'binary' for that value led me to make this decision
Copy link

github-actions bot commented Apr 29, 2025

✔️ Linting Passed

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

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

Comment on lines -1798 to +1796
average=None,
average="binary",
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 the documentation should follow the code, not the other way around. Changing this would change existing code behavior.

Copy link
Author

Choose a reason for hiding this comment

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

Changed the documentation instead, and returned the code

The original aim might be the opposite to this commit, leaving it as it was(None), and changing the documentation.
However, the fact that the original documentation explicitly mentions 'binary' for that value led me to make this decision
@Foundsheep Foundsheep force-pushed the fix_prfs_default_value branch from 40502b3 to 3ff208f Compare May 7, 2025 05:59
@adrinjalali
Copy link
Member

CI error is related.

Also, please avoid force pushing to your branch here, since it makes review harder.

@Foundsheep
Copy link
Author

Sorry about that.

I'm not familiar with PR that much. If I'm not pushing my branch, then how could I modify the code and update the PR?
Also, I'm not sure how to solve CI error, since there's nothing much I committed to the code in relation to that issue.

@adrinjalali
Copy link
Member

You push to your branch, but don't force push to the branch. Make sure you merge with main instead of rebasing if that's the issue.

If you look at the failing CI, you see this message:

>               raise AssertionError(msg)
E               AssertionError: The type specification of Parameter 'average' is inconsistent between
E               ['precision_recall_fscore_support'] and ['f1_score', 'fbeta_score',
E               'precision_score', 'recall_score']:
E               
E               *** ['precision_recall_fscore_support']
E               --- ['f1_score', 'fbeta_score', 'precision_score', 'recall_score']
E               ***************
E               
E               *** 1,8 ****
E               
E                 {'micro', 'macro', 'samples', 'weighted', 'binary'} or None,
E               ! default=None
E               --- 1,8 ----
E               
E                 {'micro', 'macro', 'samples', 'weighted', 'binary'} or None,
E               ! default='binary'

That's a test which makes sure things are consistently documented. In this case, you need to check if the other functions also need a change, or if only this one needs a change and instead the test needs to be fixed.

@Foundsheep
Copy link
Author

@adrinjalali

Thanks for the detailed guide, but I still need some more help.

  1. I just pushed to my remote branch using git push and I'm not sure how it did force-push, which hinders me from making another commit
  2. Where could I get that error script? I looked at https://github.com/scikit-learn/scikit-learn/actions/runs/14876302969/job/41774196534?pr=31270 and elsewhere I could check, but I think I'm missing this bit. All the error message I can see is related to TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'

@lucyleeow
Copy link
Member

It seems that the other related functions set default average='binary' whereas for precision_recall_fscore_support it is None (and has been the case for the last 11 years).

What do you think about this difference in default values @adrinjalali ? Note 'binary' gives you the values for the pos_label class, whereas None gives you all the values.

@adrinjalali
Copy link
Member

What do you think about this difference in default values @adrinjalali ? Note 'binary' gives you the values for the pos_label class, whereas None gives you all the values.

hmm, not sure. I wouldn't mind changing the default via a deprecation cycle to make them all consistent.

I just pushed to my remote branch using git push and I'm not sure how it did force-push, which hinders me from making another commit

Just make sure you do git merge instead of git rebase and that you don't do git push -f

And the error is in this CI run: https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=76333&view=logs&j=f71949a9-f9d9-549e-cf45-2e99c7b412d1&t=d5baef2b-8bda-5a4c-e848-157b5caff279

@lucyleeow
Copy link
Member

I wouldn't mind changing the default via a deprecation cycle to make them all consistent.

I was thinking the same. Maybe cc @glemaitre or @lorentzenchr may be interested to weigh in?

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.