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 for missing class prediction #90

Open tanfiona opened 2 years ago

tanfiona commented 2 years ago

I'm using the Huggingface implementation of seqeval, example codes as follows:

from datasets import load_metric

predictions = [['B-E', 'I-E', 'O', 'O', 'O', 'O', 'O', 'O']]
references = [['B-E', 'I-E', 'O', 'O', 'B-C', 'I-C', 'I-C', 'O']]

metric = load_metric('seqeval')
for i in range(len(predictions)):
    metric.add(
        prediction=predictions[i],
        reference=references[i] 
    )
results = metric.compute()
print(results)

My question is about the reported Overall F1 score. Given the references = [['B-E', 'I-E', 'O', 'O', 'B-C', 'I-C', 'I-C', 'O']]:

Why is the F1 score higher for the second case with missing "C" class predictions? Shouldn't both cases return the same Overall F1 score? By the way, in both cases, F1 score for "C" is 0.

Thanks!