GaussianF1Score#
- class GaussianF1Score(*, sigma_fraction=0.01, min_sigma=1.0, adaptive_sigma=False, convert_labels_to_segments=False)[source]#
Gaussian-weighted alternative to the classic F1 score.
The metric operates in three conceptual steps:
- Preparation – convert optional label sequences into change point
lists, remove boundary markers, and infer the series length.
- Gaussian matching – every true change point is associated with a
Gaussian of width
sigma_fraction * n(clamped below bymin_sigma). Predictions are rewarded according to that shared kernel, and each prediction is paired with at most one true change point (and vice versa) so that the summed reward is maximal (an optimal assignment, not a greedy one).
- Soft precision & recall – derive precision and recall from the sum of
Gaussian rewards, yielding a fuzzy F1 in \([0, 1]\).
Special cases are handled explicitly:
- No ground-truth change point – if the data really is stationary and no
change points are predicted either, we return the perfect score 1.0. Conversely, predicting spurious changes yields a zero score.
- Single change point – the Gaussian spread still follows the global
fraction, ensuring a consistent reward scale across all events.
sigma_fractionmust be finite and non-negative.min_sigmamust be finite and strictly positive so the Gaussian width never reaches zero.- __init__(*, sigma_fraction=0.01, min_sigma=1.0, adaptive_sigma=False, convert_labels_to_segments=False)[source]#
Initializes the metric with optional parameters.
Methods
__init__(*[, sigma_fraction, min_sigma, ...])Initializes the metric with optional parameters.
compute(y_true, y_pred, *[, n_timepoints])Return the Gaussian-weighted precision, recall, and F1 score.