changepoint_recall#

changepoint_recall(changepoints_true: ArrayLike, changepoints_pred: ArrayLike, *, tolerance: int = 5) float[source][source]#

Compute detection recall for changepoints with a tolerance window.

The fraction of true changepoints that are matched by a predicted changepoint within tolerance samples (greedy matching). Higher is better.

Returns 1.0 when there are no true changepoints (nothing to miss).

Parameters:
changepoints_truearray-like of shape (n_changepoints_true,)

True changepoint indices, as returned by predict_changepoints().

changepoints_predarray-like of shape (n_changepoints_pred,)

Predicted changepoint indices, as returned by predict_changepoints().

toleranceint, default=5

Maximum sample distance for a match to count as correct.

Returns:
float

Recall in [0, 1].

Examples

>>> changepoint_recall([10, 20], [12, 20], tolerance=5)
1.0