tsseg.algorithms.kcpd package
KCPD — Kernel Change Point Detection.
Description
KCPD operates in a Reproducing Kernel Hilbert Space (RKHS) and detects mean-shifts in the mapped signal. The time series is implicitly mapped by a kernel function \(k(\cdot,\cdot)\) and the algorithm minimises:
When the number of changes K is known, the exact minimum is found by dynamic programming; otherwise a penalised formulation (PELT) is used.
Available kernels: "linear" (L2 cost), "rbf" (Gaussian), "cosine".
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int / None |
|
Number of change points. |
|
float / None |
|
Penalty for the penalised optimisation. |
|
str |
|
Kernel to use ( |
|
int |
|
Minimum segment length. |
|
int |
|
Sub-sampling factor for candidates. |
|
dict / None |
|
Extra arguments for the kernel cost. |
|
int |
|
Time axis. |
Usage
from tsseg.algorithms import KCPDDetector
detector = KCPDDetector(kernel="rbf", n_cps=3)
labels = detector.fit_predict(X)
# Unknown K — use a penalty
detector = KCPDDetector(kernel="rbf", pen=10)
labels = detector.fit_predict(X)
Implementation: Vendored from ruptures v1.1.8 (C implementation). BSD 2-Clause.
Reference: Celisse, Marot, Pierre-Jean & Rigaill (2018), Computational Statistics and Data Analysis; Arlot, Celisse & Harchaoui (2019), JMLR.
Submodules
tsseg.algorithms.kcpd.detector module
Kernel-based change point detector built on the vendored ruptures implementation.
- class tsseg.algorithms.kcpd.detector.KCPDDetector(*, n_cps=None, pen=10, kernel='rbf', min_size=2, jump=1, cost_params=None, axis=0)[source]
Bases:
BaseSegmenterKernel change point detector using dynamic programming or PELT.
- set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') KCPDDetector
Configure whether metadata should be requested to be passed to the
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.
- set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') KCPDDetector
Configure whether metadata should be requested to be passed to the
predictmethod.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(seesklearn.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 topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.
Module contents
Kernel change point detector.