Segmentation#

Segmentation of multivariate time series.

Cost functions and search strategies (costs, search), latent-variable segmentation (latent, fuzzy, fisher), probabilistic and self-supervised methods (bayesian, hmm, profiles, states, predictive), ensembles, model selection and streaming.

Segment costs and search strategies, latent-variable, fuzzy and Fisher-information segmentation, Bayesian, HMM, profile, state, predictive, consensus and on-line segmenters, model selection.

Classes#

BaseSegmenter()

Common interface of all segmentation methods.

BaseCost()

Interface: fit(X) then error(a, b) for the samples X[a:b].

CostL2()

Sum of squared deviations from the segment mean (piecewise constant model).

CostL1()

Sum of absolute deviations from the segment median (robust to outliers).

CostNormal([ridge])

Gaussian negative log-likelihood with segment-wise mean and full covariance, \((b-a)\log\det\hat\Sigma_{ab}\) (up to constants).

CostLinear()

Residual sum of squares of a straight line fitted to every variable against time (piecewise linear approximation, PLA; Keogh and Pazzani, 1998).

CostAR([order])

Residual sum of squares of autoregressive models of the given order fitted to every variable inside the segment (detects changes of the dynamics of univariate signals).

CostPCA([n_components, statistic, lags, ...])

Principal component analysis based homogeneity cost.

CostKernel([kernel, gamma, approx, ...])

Kernel cost (Harchaoui and Cappé, 2007; Arlot, Celisse and Harchaoui, 2019): dispersion of the segment in the feature space of a kernel, \(\sum_{i\in S}k_{ii}-\frac1{\lvert S\rvert}\sum_{i,j\in S}k_{ij}\).

CostRegression([targets, inputs, intercept, ...])

Model-based cost: residual sum of squares of a linear regression of the targets on the inputs inside the segment.

BottomUp([cost, n_segments, penalty, ...])

Bottom-up segmentation by greedy merging of adjacent segments.

TopDown([cost, n_segments, penalty, ...])

Binary segmentation: repeatedly split the segment whose best split reduces the total cost most.

SlidingWindow([cost, max_error, normalize, ...])

Grow each segment from its start until its cost exceeds max_error (Keogh et al., 2001); suitable for streaming data.

SWAB([cost, max_error, buffer_size, ...])

Sliding Window And Bottom-up (Keogh et al., 2001): bottom-up segmentation inside a moving buffer, emitting the leftmost segment.

OptimalPartition([cost, n_segments, ...])

Exact minimization of the total cost for a fixed number of segments by dynamic programming over a grid of candidate change points.

PELT([cost, penalty, min_size, jump, ...])

Pruned Exact Linear Time search (Killick et al., 2012): minimizes \(\sum_i cost(S_i)+\beta\,(c-1)\) exactly, pruning candidates that can never be optimal.

WindowDiscrepancy([cost, width, n_segments, ...])

Sliding two-window discrepancy \(d(t)=cost(t-w,t+w)-cost(t-w,t)-cost(t,t+w)\) and peak picking (Truong, Oudre and Vayatis, 2020).

MergeTree(initial, removed, criterion, ...)

Hierarchy of segmentations produced by bottom-up merging.

PCASegmenter([n_segments, n_components, ...])

Segmentation by the homogeneity of local PCA models.

DPCASegmenter([n_segments, lags, ...])

Process-dynamics-aware segmentation with dynamic PCA.

KrzanowskiSegmenter([n_segments, threshold, ...])

Off-line bottom-up segmentation by the similarity of neighbouring (dynamic) PCA models.

RecursivePCASegmenter([threshold, ...])

On-line segmentation with recursive (dynamic) PCA.

GGSegmenter([n_segments, n_components, m, ...])

Fuzzy segmentation with time-constrained PPCA clusters.

FisherSegmenter([method, n_segments, ...])

Segmentation of historical data by the information they carry on the parameters of a process model.

BOCPD([hazard, model, prior_kappa, ...])

Bayesian on-line change point detection.

GaussianHMMSegmenter([n_states, covariance, ...])

State detection with a Gaussian HMM.

ClaSPSegmenter([width, n_segments, k, ...])

Recursive segmentation by classification score profiles.

FLUSSSegmenter([width, n_segments, ...])

Regime extraction with the corrected arc curve (FLUSS).

StateSegmenter([segmenter, n_states, ...])

Segment-then-cluster state detection.

SparseGaussianStateSegmenter([n_states, ...])

TICC-style state detection with sparse Gaussian window models.

NeighborMergeSegmenter(dissimilarity[, ...])

Bottom-up merging of adjacent segments by a pairwise dissimilarity.

GraphBottomUp([n_regions])

Bottom-up merging of connected regions of a graph.

ClassifierHomogeneity([estimator, cv, ...])

Dissimilarity of two segments by a classifier two-sample test.

RegressionHomogeneity([estimator, mode, ...])

Dissimilarity of two segments by cross-prediction.

PredictiveSegmenter([kind, estimator, ...])

Bottom-up segmentation by predictive homogeneity.

ConsensusSegmenter(segmenters[, bandwidth, ...])

Ensemble segmentation by boundary agreement.

StreamSegmenter(segmenter[, window, step, guard])

Windowed application of a batch segmenter to a stream.

CUSUMDetector([k, h, warmup])

Multivariate CUSUM change detector.

Functions#

get_cost(cost, **kwargs)

Return a cost object from a name (see COSTS) or pass an instance through.

bic_penalty(cost[, X])

BIC-type penalty for PELT: n_params * log(T) * sigma2.

pca_segment_models(X, segmentation[, ...])

Fit a (dynamic) PCA model to every segment of a segmentation.

monotone_labels(U[, min_length])

Contiguous crisp segmentation that agrees best with fuzzy memberships.

fisher_information(S[, a, b, Q, normalize])

Fisher information matrix of the samples [a, b) from the sensitivities S (T, p) or (T, n_outputs, p); Q is the inverse measurement-error covariance of the outputs.

oed_criteria(F[, ridge])

OED criteria of a Fisher information matrix.

criterion_series(S, window[, criterion, Q, ...])

Moving-window OED criterion: the "evaluating time series" of Dobos, Bankó and Abonyi (2010).

finite_difference_sensitivities(simulate, params)

Output sensitivities \(\partial y/\partial p\) by forward finite differences.

arx_sensitivities(u, y[, na, nb, delay])

Sensitivities of the one-step-ahead prediction of an ARX model, \(\hat y(k)=\sum_i a_i y(k-i)+\sum_j b_j u(k-d-j+1)\), with respect to its parameters: the regressor vector itself.

clasp_profile(X, width[, k, exclusion, ...])

Classification score profile of one series (or of X restricted to a range): entry i scores the split before subsequence i.

arc_curve(mp_index, width[, exclusion_factor])

Corrected arc curve (CAC) of FLUSS from a matrix profile index.

segment_descriptors(X, segmentation[, kind, ...])

Local model of every segment.

segment_distance_matrix(descriptors[, ...])

Pairwise distances of segment descriptors.

boundary_agreement(segmentations, n_samples)

Boundary agreement profile of a list of segmentations (or change point arrays) of the same series.

cost_curve(X[, cost, max_segments, ...])

Total cost of the bottom-up segmentation for 1..max_segments segments (one merge run).

relative_reduction(curve)

Relative reduction rate \(RR(c)\) of a cost curve.

knee_point(x, y[, direction])

Knee of a convex decreasing (or concave increasing) curve: the point farthest from the chord between the end points of the normalized curve.

permutation_test_segments(X[, cost, ...])

Permutation test for the number of segments.

select_n_segments(X[, cost, method, ...])

Choose the number of segments of a cost-based segmentation.

penalty_path(X[, cost, penalties, ...])

Number of change points found by PELT for a range of penalties.

segment(X[, method])

One-line segmentation: segment(X, "pca", n_segments=4).

Constants#