mvtsa.segmentation.CostPCA#
- class mvtsa.segmentation.CostPCA(n_components=0.95, statistic='Q', lags=0, aggregate='sum', scale=True)[source]#
Bases:
BaseCostPrincipal component analysis based homogeneity cost.
For the samples of a segment a local PCA model with \(p\) components is fitted; with \(\lambda_1\ge\dots\ge\lambda_n\) the eigenvalues of the segment covariance,
statistic="Q": \(\sum_{t\in S}Q(t)=\lvert S\rvert\sum_{i>p}\lambda_i\), the reconstruction error outside the principal subspace (change of the correlation structure);statistic="T2": \(\sum_{t\in S}T^2(t)=\lvert S\rvert\sum_{i\le p}\lambda_i\) with the unscaled \(T^2\) of Bankó (2015), the variation inside the subspace (drift of the operating point);statistic="both": their sum, which equals the L2 cost.
- Parameters:
- n_components
int,floatorstr Retained components (fixed number, or a variance fraction resolved on the whole series and then kept fixed for every segment). For
statistic="Q"at mostn - 1components are kept, since the Q cost of the full model is zero.- statistic{“Q”, “T2”, “both”}
- lags
int Dynamic PCA (Bankó, Dobos and Abonyi, 2011): the costs are computed on the lag-extended matrix; segment
[a, b)uses the lagged rows whose current sample lies in[a, b).- aggregate{“sum”, “mean”}
"mean"divides by the segment length (equation 3.1 of Bankó, 2015);"sum"keeps costs additive.- scalebool
Standardize the variables of the whole series first.
- n_components