chakki-works / seqeval

A Python framework for sequence labeling evaluation(named-entity recognition, pos tagging, etc...)
MIT License
1.09k stars 129 forks source link

F1-score issue #68

Closed rajae-Bens closed 4 years ago

rajae-Bens commented 4 years ago

Hi,

I am trying to execute the code in this google colab notebook

https://colab.research.google.com/github/abhimishra91/transformers-tutorials/blob/master/transformers_ner.ipynb#scrollTo=9zwFzzBriLMO

but an error is generated when calculating the f1 score in the validation step

Screen Shot 2020-10-28 at 9 12 02 AM

could someone help plz thank u

Hironsan commented 4 years ago

You should give a list of lists to f1_score:

>>> from seqeval.metrics import f1_score
>>> y_true = [['O', 'O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]
>>> y_pred = [['O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]
>>> f1_score(y_true, y_pred)
0.50