huggingface / huggingface/evaluate

Calculating F1 fails due to error(AttributeError: 'float' object has no attribute 'size')

Open
#658 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.5k
Forks
341
PR merge metrics
No merged PRs in 30d

Description

When I try to calculate `f1` score I get this error:
```
return {"f1": float(score) if score.size == 1 else score}
^^^^^^
AttributeError: 'float' object has no attribute 'size'
```

Code to Reproduce

```py
import evaluate
f1_metric = evaluate.load("f1")
result = f1_metric.compute(predictions=[0, 1], references=[0, 1])
print(result["f1"])
```

- Tested on a default github codespaces environment and google colab.
- evaluate==0.4.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.