cost_factory#
- cost_factory(cost: str | tuple[Callable, Callable])[source]#
Return cost function and its initializer.
- Parameters:
- cost{“mean”}, tuple[Callable, Callable], default=”mean
Name of cost function to use for changepoint detection.
“mean”: The Gaussian mean likelihood cost is used.
If a tuple, it must contain two numba jitted functions:
The first function is the cost function, which takes three arguments:
precomputed_params: The output of the second function.
starts: Start indices of the intervals to calculate the cost for.
ends: End indices of the intervals to calculate the cost for.
The algorithms that use the cost function govern what intervals are considered.
The second function is the initializer, which takes the data matrix as input and returns precomputed quantities that may speed up the cost calculations. If not relevant, just return the input data matrix.
- Returns:
- cost_funcCallable
Cost function.
- init_cost_funcCallable
Cost function initializer.
- Raises:
- ValueError
If the provided cost is not recognized, an error is raised with a message indicating the valid options.