Skip to content

Exception when computing f1 metrics with average='macro' and zero_division=0.0 #161

@Utanapishtim31

Description

@Utanapishtim31

Describe the bug
Using metrics.f1 with average='macro' and zero_division=0.0 raises the following exception:

TypeError: _f_score_micro() missing 1 required positional argument: 'zero_division'

Minimal example:

`
from hiclass import metrics

y_true = [0, 1]
y_pred = [1, 1]

metrics.f1(y_true, y_pred, average='macro', zero_division=0.0)
`

The problem comes from the test at line 318 in metrics.py:

if zero_division:

which is false if zero_division = 0.0.

A better test would be:

if zero_division is not None

  • Version: 5.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions