FIX: Handle single class edge case in balanced_accuracy_score(adjusted=True) - #34937
FIX: Handle single class edge case in balanced_accuracy_score(adjusted=True)#34937deepekaguru wants to merge 1 commit into
Conversation
|
Thank you for your interest in contributing to scikit-learn. The linked issue is still under discussion, and the maintainers have not yet reached consensus on how it should be resolved. Before opening a pull request, please review the "Issues tagged 'Needs Triage'" section of the Contributing Guide: For now, we are closing this pull request.
|
❌ Linting issuesThis PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling You can see the details of the linting issues under the
|
Issue
Fixes #34889 -
balanced_accuracy_score(adjusted=True)returns-infwhen only one class survives NaN filtering.Root Cause
The adjustment formula:
score = (score - chance) / (1 - chance)When only 1 class survives:
chance = 1/1 = 1.0denominator = 1 - 1.0 = 0→ division by zero →-infSolution
Added validation check to raise informative
ValueErrorwhen only one class is present withadjusted=True.Closes #34889