metrics
aiice.metrics
Evaluator
Compute and aggregate evaluation metrics over multiple evaluation steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
`dict[str, MetricFn]`, `list[str]`
|
Metrics to use. If a list of strings is provided, metrics are resolved from the built-in registry. If None, default metrics are used. |
None
|
accumulate
|
`bool`
|
Whether to accumulate metric values across multiple |
True
|
Source code in src/aiice/metrics.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
eval
eval(y_true: Sequence, y_pred: Sequence) -> dict[str, float]
Evaluate all metrics on a single batch or sample and updates the internal
report state depending on the accumulate mode.
Source code in src/aiice/metrics.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
report
report(detailed: bool = True) -> dict[str, dict[str, float] | float]
Return aggregated statistics for all evaluated metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detailed
|
`bool`
|
If True, returns full statistics for each metric including: mean, last value, count, min, and max. If False, returns only the mean value per metric. |
True
|
Source code in src/aiice/metrics.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
mae
mae(y_true: Sequence, y_pred: Sequence) -> float
MAE (mean absolute error) - determines absolute values range coincidence with real data.
Source code in src/aiice/metrics.py
32 33 34 35 36 37 38 39 | |
mse
mse(y_true: Sequence, y_pred: Sequence) -> float
MSE (mean squared error) - similar to MAE but emphasizes larger errors by squaring differences.
Source code in src/aiice/metrics.py
42 43 44 45 46 47 48 49 | |
rmse
rmse(y_true: Sequence, y_pred: Sequence) -> float
RMSE (root mean square error) - determines absolute values range coincidence as MAE but making emphasis on spatial error distribution of prediction.
Source code in src/aiice/metrics.py
52 53 54 55 56 57 58 59 60 | |
psnr
psnr(y_true: Sequence, y_pred: Sequence) -> float
PSNR (peak signal-to-noise ratio) - reflects noise and distortion level on predicted images identifying artifacts.
where \(\text{MAX}\) is the maximum value of the ground truth field.
Source code in src/aiice/metrics.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
bin_accuracy
bin_accuracy(y_true: Sequence, y_pred: Sequence, threshold: float = 0.15) -> float
Binary accuracy - binarization of ice concentration continuous field with threshold which causing the presence of an ice edge gives us possibility to compare binary masks of real ice extent and predicted one.
where \(b_i = \mathbf{1}[y_i > \tau]\) and \(\hat{b}_i = \mathbf{1}[\hat{y}_i > \tau]\) are binary masks obtained by thresholding with \(\tau\).
Source code in src/aiice/metrics.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
ssim
ssim(y_true: Sequence, y_pred: Sequence) -> float
SSIM (structural similarity index measure) - determines spatial patterns coincidence on predicted and target images
where \(\mu_x, \mu_y\) are local means, \(\sigma_x^2, \sigma_y^2\) are local variances, \(\sigma_{xy}\) is cross-covariance, and \(c_1, c_2\) are stabilization constants.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/aiice/metrics.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
iou
iou(y_true: Sequence, y_pred: Sequence, threshold: float = 0.15) -> float
IoU (Intersection over Union) - measures overlap between binary masks of ground truth and prediction.
Similar to bin_accuracy but focuses on overlap quality instead of per-pixel equality.
where \(B = \mathbf{1}[y > \tau]\) and \(\hat{B} = \mathbf{1}[\hat{y} > \tau]\) are binary ice extent masks.
Source code in src/aiice/metrics.py
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 | |