mvtsa.segmentation.CostPCA#

class mvtsa.segmentation.CostPCA(n_components=0.95, statistic='Q', lags=0, aggregate='sum', scale=True)[source]#

Bases: BaseCost

Principal 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_componentsint, float or str

Retained components (fixed number, or a variance fraction resolved on the whole series and then kept fixed for every segment). For statistic="Q" at most n - 1 components are kept, since the Q cost of the full model is zero.

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

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_params()[source]#

Number of free parameters of one segment model (for BIC/MDL penalties).

segment_model(a, b)[source]#

Mean, loadings (n', p) and eigenvalues of the segment model.