fuzzyclust.timeseries.make_piecewise_timeseries#

fuzzyclust.timeseries.make_piecewise_timeseries(n_samples=2000, n_features=6, n_latent=2, change_points=(500, 1000, 1500), change_kinds=('correlation', 'mean', 'both'), mean_shift=4.0, noise=0.2, latent_noise=0.5, random_state=None)[source]#

Multivariate series with planted regime changes (segmentation benchmark).

Mimics the synthetic data set of Abonyi et al. (2005): n_latent hidden variables \(\mathbf{y}_k\) are drawn around a piecewise-constant mean, and the observed variables are linear mixtures \(\mathbf{x}_k=\mathbf{W}\mathbf{y}_k+\boldsymbol{\varepsilon}_k\). At every change point one of three things happens:

  • "mean" – the mean of the latent variables jumps (the hyperplane of the observations is shifted but keeps its orientation);

  • "correlation" – the mixing matrix \(\mathbf{W}\) is replaced (the correlation structure of the observations changes while the mean is kept);

  • "both" – both change.

The true segment of every sample is returned, so that segmentation algorithms can be evaluated. A segmentation that uses only one variable cannot see a pure correlation change.

Parameters:
n_samplesint, default=2000
n_featuresint, default=6

Number of observed variables \(n\).

n_latentint, default=2

Number of latent variables (the rank of the local PCA models).

change_pointssequence of int, default=(500, 1000, 1500)

Sample indices where a new segment starts.

change_kindssequence of {“mean”, “correlation”, “both”}

What changes at every change point (same length as change_points).

mean_shiftfloat, default=4.0

Scale of the latent mean jumps.

noisefloat, default=0.2

Standard deviation of the observation noise.

latent_noisefloat, default=0.5

Standard deviation of the latent variables around their mean.

random_stateint, RandomState instance or None
Returns:
Xndarray of shape (n_samples, n_features)
yndarray of shape (n_samples,)

True segment index of every sample (0, 1, ... in time order).

Examples

>>> from fuzzyclust.timeseries import make_piecewise_timeseries
>>> X, seg = make_piecewise_timeseries(n_samples=400, change_points=(200,),
...                                    change_kinds=("mean",), random_state=0)
>>> X.shape, seg.max()
((400, 6), np.int64(1))

Examples using fuzzyclust.timeseries.make_piecewise_timeseries#

Fuzzy segmentation of a multivariate time series

Fuzzy segmentation of a multivariate time series

Bottom-up segmentation with PCA models versus fuzzy segmentation

Bottom-up segmentation with PCA models versus fuzzy segmentation