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:
BaseSegmenterSegmentation by the homogeneity of local PCA models.
- Parameters:
- n_segments
int Number of segments (see
mvtsa.segmentation.selectionfor choosing it from the cost curve).- n_components
int,floatorstr 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_size
int 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.
- lags
int Lags of dynamic PCA (0: static PCA).
- n_segments
- Attributes:
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]