metrics¶
- class mfai.pytorch.metrics.CSINeighborhood(num_neighbors, task, num_classes=0, average='macro')[source]¶
Bases:
MetricCompute Critical Sucess Index (or Threat Score) over a neighborhood to avoid the phenomenon of double penalty. So a forecast is considered as a true positive if there is a positive observation in the neighborood (define here by the number of neighbors num_ngb) of a positive prediction.
For further information on the CSI: https://resources.eumetrain.org/data/4/451/english/msg/ver_categ_forec/uos2/uos2_ko4.htm
- Parameters:
- binary_dilation_(input_tensor)[source]¶
Performs IN_PLACE binary dilation of input_tensor Tensor. input_tensor is assumed to be an implicit single channel tensor of shape (MINIBATCH, W, H).
- class mfai.pytorch.metrics.FAR(*args, **kwargs)[source]¶
Bases:
MetricFalse Alarm Rate.
FAR = FP / (TP + FP) = 1 - (TP / (TP + FP)) = 1 - Precision
- class mfai.pytorch.metrics.FNR[source]¶
Bases:
MetricFalse Negatives Rate.
FNR = FN / (TP + FN) = 1 - (TP / (TP + FN)) = 1 - Sensitivity torchmetrics.Sensitivity is not available yet so we implement the calculation.
- class mfai.pytorch.metrics.FSS(neighborood, thresholds=None, num_classes=None, stride=None, mask=False)[source]¶
Bases:
MetricFraction Skill Score.
The FSS is normally computed over a sample of forecast-observation pairs, e.g., at different valid times. Mitter- maier (2021) has demonstrated that the FSS is sensitive to the pooling method used to combine the scores of different forecasts. The two possibilities are to average the FSS of all individual forecast-observation pairs, or to aggregate the FSS components (fractions Brier Score (FBS) and worst possible FBS (WFBS)) before computing an overall score. We use this last method to compute the FSS, called pFSS by Necker, T. & al. (2024).
FSS = 1 - (FBS / WFBS)
References: - Mittermaier, M.P. (2021) A “meta” analysis of the fractions skill score: The limiting case and implications for aggregation. Monthly Weather Review, 149(10), 3491–3504. Available from: https://doi.org/10.1175/MWR-D-18-0106.1 - Necker, T. et al. (2024), The fractions skill score for ensemble forecast verification. Quarterly Journal of the Royal Meteorological Society, 150(764), 4457–4477. Available from: https://doi.org/10.1002/qj.4824
- Parameters:
- compute()[source]¶
Override this method to compute the final metric value.
This method will automatically synchronize state variables when running in distributed backend.
- Return type:
- compute_fbs_wfbs(targets, preds)[source]¶
Compute the fractions Brier Score (FBS) and the worse fractions Brier Score (WFBS).
- class mfai.pytorch.metrics.PR_AUC(task='binary')[source]¶
Bases:
MetricArea Under the Precsion-Recall Curve.
- Parameters:
task (Literal['binary', 'multiclass', 'multilabel'])