Flair: Getting tagwise accuracy/fscore metrics in sequence tagger

Created on 7 Jun 2019  路  3Comments  路  Source: flairNLP/flair

I am training a multi-class sequence tagger. How to get various evaluation ma=etrics like accuracy and fscore for each tag separately?

question

All 3 comments

@mnishant2 as @CamielK pointed out you can use the evaluate function of the tagger to do this:

from flair.datasets import ColumnCorpus
from flair.models import SequenceTagger

corpus: ColumnCorpus = ColumnCorpus('path/to/your/corpus', column_format={0: 'text', 1: 'ner'})

tagger: SequenceTagger = SequenceTagger.load('ner')
result, _ = tagger.evaluate(corpus.test)
print(result.detailed_results)

Closing this issue for now, but feel free to reopen if you have more questions!

A small correction:
Instead of
result, _ = tagger.evaluate(corpus.test)
we need
result, _ = tagger.evaluate([corpus.test])

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inyukwo1 picture inyukwo1  路  3Comments

ciaochiaociao picture ciaochiaociao  路  3Comments

frtacoa picture frtacoa  路  3Comments

aschmu picture aschmu  路  3Comments

gopalkalpande picture gopalkalpande  路  3Comments