pelt documentation
- pelt.predict(signal, penalty, segment_cost_function='l1', jump=10, minimum_segment_length=2)
Calculate the changepoints.
- Parameters:
signal (
numpy.typing.NDArray[numpy.float64]) – 1D or 2D input signal array. Can only contain numbers.Nonevalues are not accepted.penalty (float) – Penalty value for each changepoint added. Larger values result in fewer changepoints detected.
segment_cost_function (str, optional) –
Determines how the cost of each potential segment is calculated. Must be one of:
"l1"- L1 cost function (least absolute deviation)"l2"- L2 cost function (least squared deviation)
Defaults to
"l1".jump (int, optional) – Step size between candidate changepoint positions. Must be > 0. If
jump = 1, a check is done every possible prior change point, guaranteeing an exact solution, finding the true minimum of the objective function. Ifjump > 1, previous change points are considered at intervals ofjump. This speeds up the computation, but the solution becomes approximate. Defaults to 10.minimum_segment_length (int, optional) – Minimum number of allowable number of data points within a segment. Must be positive. Defaults to 2.
- Returns:
1D array of zero-based indices where changes in the signal were detected.
- Return type:
numpy.typing.NDArray[numpy.uint64]- Raises:
ValueError – If the array has invalid dimensions or if any of the parameters are outside their valid ranges.
Examples
>>> from pelt import predict >>> changepoints = predict(signal, penalty=20.0, segment_cost_function="l1", jump=10, minimum_segment_length=2) >>> print(changepoints)