tsseg.algorithms.pelt package

PELT — Pruned Exact Linear Time change point detection.

Description

PELT solves the penalised change point optimisation problem exactly by pruning the search space with a dynamic-programming rule. Under mild conditions on the change point distribution, the average complexity is \(O(C\,K\,n)\) — linear in the number of samples — where K is the number of change points and C the cost function complexity. In practice, "l2" cost models are significantly faster than linear or autoregressive ones.

Key tuning levers:

  • penalty — higher values produce fewer change points.

  • min_size — minimum distance between change points.

  • jump — grid step for admissible positions.

Type: change point detection
Supervision: fully unsupervised
Scope: univariate and multivariate
Complexity: \(O(C\,K\,n)\) average

Parameters

Name

Type

Default

Description

model

str

"l2"

Ruptures cost model.

min_size

int

2

Minimum segment length.

jump

int

5

Grid step for candidate positions.

penalty

float

10.0

Penalty threshold for the PELT stopping criterion.

cost_params

dict / None

None

Extra keyword arguments for the cost factory.

axis

int

0

Time axis.

Usage

from tsseg.algorithms import PeltDetector

detector = PeltDetector(model="l2", penalty=10)
labels = detector.fit_predict(X)

Implementation: Vendored from ruptures v1.1.8. BSD 2-Clause.

Reference: Killick, Fearnhead & Eckley (2012), Optimal detection of changepoints with a linear computational cost, JASA.

Submodules

tsseg.algorithms.pelt.detector module

PELT change point detector using the vendored ruptures implementation.

class tsseg.algorithms.pelt.detector.PeltDetector(*, model='l2', min_size=2, jump=5, penalty=10.0, cost_params=None, axis=0)[source]

Bases: BaseSegmenter

Wrapper around the vendored ruptures Pelt estimator.

property change_points_: ndarray
set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') PeltDetector

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') PeltDetector

Configure whether metadata should be requested to be passed to the predict method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

object

Module contents

Utilities for the PELT segmentation baseline.