Metrics
npfl138.metrics.BIOEncodingF1Score
Bases: Module
Metric for evaluating F1 score of BIO-encoded spans.
Source code in npfl138/metrics.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 |
|
__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.py
15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
reset
reset() -> Self
Reset the metric to its initial state.
Returns:
-
Self
–self
Source code in npfl138/metrics.py
29 30 31 32 33 34 35 36 37 38 |
|
update
Update the metric with new predictions and targets.
Returns:
-
Self
–self
Source code in npfl138/metrics.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
compute
compute() -> Tensor
Compute the F1 score.
Source code in npfl138/metrics.py
65 66 67 |
|
npfl138.metrics.EditDistance
Bases: Module
An implementation of mean edit distance metric.
Source code in npfl138/metrics.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
__init__
__init__(ignore_index: int | None = None) -> None
Construct a new EditDistance metric.
Parameters:
-
ignore_index
(int | None
, default:None
) –If not None, the gold index to ignore when computing the edit distance. The default is None, which means no index is ignored.
Source code in npfl138/metrics.py
73 74 75 76 77 78 79 80 81 82 83 |
|
reset
reset() -> Self
Reset the metric to its initial state.
Returns:
-
Self
–self
Source code in npfl138/metrics.py
85 86 87 88 89 90 91 92 93 |
|
update
Update the metric with new predictions and targets.
Returns:
-
Self
–self
Source code in npfl138/metrics.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
compute
compute() -> Tensor
Compute the mean edit distance.
Source code in npfl138/metrics.py
111 112 113 |
|
npfl138.metrics.MaskIoU
Bases: Module
An implementation of mean IoU metric computed on binary masks.
Source code in npfl138/metrics.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
__init__
Construct a new MaskIoU metric.
Parameters:
-
mask_shape
(Sequence[int]
) –The shape of the input masks as (H, W).
-
from_logits
(bool
, default:False
) –If
True
, the predictions are expected to be logits; otherwise, they are probabilities (the default). However, the target masks must always be probabilities.
Source code in npfl138/metrics.py
118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
reset
reset() -> Self
Reset the metric to its initial state.
Returns:
-
Self
–self
Source code in npfl138/metrics.py
132 133 134 135 136 137 138 139 140 |
|
update
Update the metric with new predictions and targets.
Returns:
-
Self
–self
Source code in npfl138/metrics.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
compute
compute() -> Tensor
Compute the mean IoU.
Source code in npfl138/metrics.py
159 160 161 |
|