Expand description
Shapelet distance core: per-window z-normalization and the sliding-window
minimum z-normalized Euclidean distance (sdist), plus the Shapelet type.
This module provides the atomic numerical primitive that every downstream
shapelet phase (discovery, transform, classifier) builds on. It is pure
&[f64] arithmetic — no nalgebra conversion, no integration weights.
§Shapelet distance definition
Given a length-L shapelet S (stored already z-normalized) and a
series T of length M ≥ L, the shapelet distance is the minimum over all
M - L + 1 sliding windows of the Euclidean distance between the shapelet
and the (independently, per-window) z-normalized window:
sdist(S, T) = min_{t = 0 .. M-L} || z(T[t : t+L]) - S ||_2Each window is z-normalized independently at comparison time — never the whole series once up front. This is what makes the distance scale- and offset-invariant (it captures shape, not amplitude/offset).
§z-normalization convention
Z-normalization here uses the population standard deviation (ddof = 0),
matching the pyts convention. (sktime/aeon variants may use ddof = 1; that
divergence is intentional and noted here.) A constant or near-constant window
(population std ≤ 1e-12) normalizes to the zero vector rather than
producing NaN/Inf.
Structs§
- Shapelet
- A discovered shapelet: a z-normalized discriminative subsequence plus its provenance in the training set.
Functions§
- shapelet_
distance - Shapelet distance
sdist: the minimum over sliding windows of the z-normalized Euclidean distance between the (pre-normalized) shapelet and each per-window-normalized window ofseries. - z_
normalize_ into - Z-normalize
srcintodstin place (population std,ddof = 0). - z_
normalize_ window - Z-normalize a window slice, returning a freshly allocated vector.