Module motifs

Source
Expand description

Temporal motif discovery via Matrix Profile.

Detects recurring patterns (motifs) and anomalous subsequences (discords) in entity trajectories. Adapted from the STOMP algorithm (Zhu et al., 2016) to operate on multi-dimensional embedding trajectories.

§Key insight

Operating on region trajectories (K ≈ 60-80 dims) rather than raw embeddings (D = 768) makes the Matrix Profile tractable: O(N² × K) for a 500-window trajectory with K=80 is ~20M operations.

§References

  • Yeh, C.-C. M. et al. (2016). Matrix Profile I. IEEE ICDM.
  • Zhu, Y. et al. (2016). Matrix Profile II: STOMP. IEEE ICDM.

Structs§

Discord
An anomalous subsequence (most unlike anything else in the trajectory).
Motif
A discovered recurring pattern in a trajectory.
MotifOccurrence
A single occurrence of a motif.

Functions§

detect_period 🔒
Detect periodicity from occurrence indices.
discover_discords
Discover the top-k anomalous subsequences (discords).
discover_motifs
Discover the top-k recurring motifs in a trajectory.
matrix_profile
Compute the Matrix Profile for a multi-dimensional trajectory.
subsequence_distance 🔒
Euclidean distance between two subsequences of the trajectory.