mvtsa.segmentation.PCASegmenter#

class mvtsa.segmentation.PCASegmenter(n_segments=2, n_components=0.95, statistic='Q', search='bottomup', initial_size=10, aggregate='sum', scale=True, lags=0)[source]#

Bases: BaseSegmenter

Segmentation by the homogeneity of local PCA models.

Parameters:
n_segmentsint

Number of segments (see mvtsa.segmentation.selection for choosing it from the cost curve).

n_componentsint, float or str

Retained principal components; a float is a fraction of variance (90–95 % is common practice, Bankó 2015).

statistic{“Q”, “T2”, “both”}

"Q" segments by the change of the correlation structure, "T2" by the drift of the operating point inside the principal subspace.

search{“bottomup”, “topdown”, “optimal”}
initial_sizeint

Initial segment length of the bottom-up search; for dynamic PCA at least five samples per lagged variable are used.

aggregate{“sum”, “mean”}

See CostPCA.

scalebool

Standardize the variables first.

lagsint

Lags of dynamic PCA (0: static PCA).

Attributes:
segmentation_Segmentation
tree_MergeTree (bottom-up search only)
models_list of PCAModel

The local PCA model of every segment.

Examples

>>> from mvtsa.datasets import make_correlation_switching
>>> X, cps, _ = make_correlation_switching(n_segments=3, length=200, random_state=0)
>>> PCASegmenter(n_segments=3, n_components=1).segment(X).change_points.tolist()
[200, 400]

Examples using mvtsa.segmentation.PCASegmenter#

PCA segmentation with the T² and Q statistics

PCA segmentation with the T² and Q statistics

Dynamic PCA segmentation

Dynamic PCA segmentation

Benchmarking segmenters with statistical tests

Benchmarking segmenters with statistical tests

Tuning segmenter parameters

Tuning segmenter parameters

Experiment tracking and model cards

Experiment tracking and model cards