# Transformers longformer classification problem with f1, precision and recall classification

**URL:** <https://discuss.huggingface.co/t/transformers-longformer-classification-problem-with-f1-precision-and-recall-classification/14721>\
**Category:** Models\
**Created:** [February 14, 2022, 6:53pm UTC](https://discuss.huggingface.co/t/transformers-longformer-classification-problem-with-f1-precision-and-recall-classification/14721 "2022-02-14T18:53:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitempe](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@nitempe](https://discuss.huggingface.co/u/nitempe)\
**Post date:** [February 14, 2022, 6:53pm UTC](https://discuss.huggingface.co/t/transformers-longformer-classification-problem-with-f1-precision-and-recall-classification/14721/1 "2022-02-14T18:53:31Z")

</div>

I am replicating code from this [page](https://github.com/jlealtru/website_tutorials/blob/main/notebooks/Longformer%20with%20IMDB.ipynb) and I am getting F1, precision and recall to be 0. I got accuracy as shown by the author. What could be reasons?

I looked into `compute_metrics` function and it seems to be correct. I tried some toy data as below and `precision_recall_fscore_support` seems to be giving a correct answer

```
from sklearn.metrics import accuracy_score, precision_recall_fscore_support

y_pred = [1, 1, 2]
y_true = [1, 2, 2]
print (accuracy_score(y_true, y_pred))

precision_recall_fscore_support(y_true, y_pred, average='binary')

0.6666666666666666
(0.5, 1.0, 0.6666666666666666, None)

```

as I am getting the accuracy it seems that the below part is working as expected

```
labels = pred.label_ids
preds = pred.predictions.argmax(-1)

acc = accuracy_score(labels, preds)

```
