Simplification#

Simplification of segmentations, representations and models.

Analysis results are often more detailed than useful: short spurious segments, state labels that flicker, a piecewise linear approximation with more pieces than needed, PCA models with superfluous components, reference collections that are too large for fast nearest-neighbour search. The functions below simplify them in a controlled, measurable way.

Merging, pruning and reducing segmentations and models; compression.

Functions#

smooth_states(labels, min_duration)

Absorb runs shorter than min_duration samples into a neighbouring run (the longer neighbour), repeatedly, until all runs are long enough.

merge_short_segments(segmentation, min_length)

Remove change points so that every segment has at least min_length samples.

prune_change_points(segmentation, X[, cost, ...])

Remove change points whose removal increases the total cost by less than min_gain (default: relative times the cost of the unsegmented series), weakest first.

reduce_segments(tree[, keep])

Coarsest level of a bottom-up merge hierarchy whose explained cost reduction is at least keep of the finest level's: \((cost_1-cost_c)/(cost_1-cost_{K}) \ge\) keep.

simplify_pla(X, max_error[, method, normalize])

Piecewise linear approximation with the fewest segments whose mean squared error per sample stays below max_error.

compression_report(X, segmentation[, kind])

Compression ratio and reconstruction error of a piecewise constant ("mean") or linear ("linear") representation.

reduce_components(model[, explained])

Return a copy of a fitted PCAModel keeping the fewest components that explain explained of the variance.

select_prototypes(D[, labels, n_per_class])

Indices of representative series: the n_per_class medoids of every class (or of the whole set) under the distance matrix D, selected greedily (k-medoids BUILD step).