score_factory#
- score_factory(score: str | tuple[Callable, Callable] = 'mean')[source]#
Return score function and its initializer.
- Parameters:
- score{“mean”, “mean_var”, “mean_cov”}, tuple[Callable, Callable], default=”mean”
Test statistic to use for changepoint detection.
“mean”: The CUSUM statistic for a change in mean (this is equivalent to a likelihood ratio test for a change in the mean of Gaussian data). For multivariate data, the sum of the CUSUM statistics for each dimension is used.
“mean_var”: The likelihood ratio test for a change in the mean and/or variance of Gaussian data. For multivariate data, the sum of the likelihood ratio statistics for each dimension is used.
“mean_cov”: The likelihood ratio test for a change in the mean and/or covariance matrix of multivariate Gaussian data.
If a tuple, it must contain two numba jitted functions:
The first function is the scoring function, which takes four arguments:
precomputed_params: The output of the second function.
starts: Start indices of the intervals to score for a change.
ends: End indices of the intervals to score for a change.
splits: Split indices of the intervals to score for a change.
For each start, split and end, the score should be calculated for the data intervals [start:split] and [split+1:end], meaning that both the starts and ends are inclusive, while split is included in the left interval.
The second function is the initializer, which takes the data matrix as input and returns precomputed quantities that may speed up the score calculations. If not relevant, just return the data matrix.
- Returns:
- score_funcNumba jitted Callable
Score function.
- init_score_funcNumba jitted Callable
Score function initializer.
- Raises:
- ValueError
If the provided score is not recognized, an error is raised with a message indicating the valid options.