BIOEncodingF1Score
npfl138.metrics.BIOEncodingF1Score
Metric for evaluating F1 score of BIO-encoded spans.
The metric employs a simple heuristic to handle invalid sequences of BIO tags. Notably:
- If there is an
Itag without precedingB/Itag, it is considered aBtag. - If the type of an
Itag does not match the type of the preceding tag, the type of thisItag is ignored (i.e., considered the same as the preceding tag type).
Source code in npfl138/metrics/bio_encoding_f1_score.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
__init__
Construct a new BIOEncodingF1Score metric.
Parameters:
-
labels(list[str]) –The list of BIO-encoded labels.
-
ignore_index(int) –The gold index to ignore when computing the F1 score.
Source code in npfl138/metrics/bio_encoding_f1_score.py
23 24 25 26 27 28 29 30 31 32 33 34 35 | |
reset
reset() -> Self
Reset the metric to its initial state.
Returns:
-
Self–self
Source code in npfl138/metrics/bio_encoding_f1_score.py
37 38 39 40 41 42 43 44 45 46 | |
update
Update the metric with new predictions and targets.
Returns:
-
Self–self
Source code in npfl138/metrics/bio_encoding_f1_score.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
compute
compute() -> Tensor
Compute the F1 score.
Source code in npfl138/metrics/bio_encoding_f1_score.py
73 74 75 | |