tsseg.algorithms.dynp package
Dynamic Programming (DynP) — exact optimal segmentation.
Description
Dynamic programming finds the exact minimum of the sum of segment costs by enumerating all admissible partitions. The user must specify the number of change points in advance (consider PELT or BinSeg when this is unknown).
Complexity is \(O(C\,K\,n^{2})\) where K is the number of change points,
n the sample count and C the cost-function complexity. To reduce runtime,
increase min_size and jump:
min_sizecontrols the minimum distance between change points.jumpcontrols the grid of admissible positions (only multiples ofjump).
n_cps required)Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Number of change points to detect (>= 0). |
|
str |
|
Ruptures cost model. |
|
int |
|
Minimum segment length. |
|
int |
|
Grid step for candidate positions. |
|
dict / None |
|
Extra arguments for the cost function. |
|
int |
|
Time axis. |
Usage
from tsseg.algorithms import DynpDetector
detector = DynpDetector(n_cps=3, model="l2")
labels = detector.fit_predict(X)
Implementation: Vendored from ruptures v1.1.8. BSD 2-Clause.
Reference: Auger & Lawrence (1989), Bulletin of Mathematical Biology.
Submodules
tsseg.algorithms.dynp.detector module
Dynamic programming detector built on the vendored ruptures implementation.
- class tsseg.algorithms.dynp.detector.DynpDetector(*, n_cps=1, model='l2', min_size=2, jump=5, cost_params=None, semi_supervised=True, axis=0)[source]
Bases:
BaseSegmenterExact dynamic programming change point detector.
- set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') DynpDetector
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$') DynpDetector
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
Dynamic programming change point detector.