Skip to content

Conversation

@Aaryaman3
Copy link

@Aaryaman3 Aaryaman3 commented Dec 15, 2025

Add zero_division parameter to F1 metric

Fixes TypeError when passing zero_division argument to F1.compute().
sklearn.metrics.f1_score raises UndefinedMetricWarning suggesting use
of zero_division parameter, but evaluate.load("f1") did not accept it.

Changes:

  • Add zero_division parameter to _compute() method (default=0)
  • Pass through to sklearn's f1_score call
  • Document parameter in kwargs description

This change adds the zero_division parameter that directly passes through to sklearn.metrics.f1_score, which already has comprehensive tests for this parameter

Resolves crashes when computing F1 with classes that have neither
predictions nor ground truth labels.

Fixes #699

Adds zero_division parameter to F1._compute() to match sklearn.metrics.f1_score
interface. Controls behavior when precision/recall denominators are zero.

Default value is 0 for backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add zero_division argument to F1

1 participant