Repository navigation
Choosing the number of motifs (k) automatically for a multi-dimensional pan matrix profile (using mstump) #1209
Unanswered
thohenadl
asked this question in
Help: Coding & Implementations
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Data. T is a multi-dimensional time series of shape (d, n), with d ≈ 20 and n ≈ 3,000–10,000. It is derived from a discrete event log: each index is one event, mapped to a fixed embedding vector. T is therefore piecewise constant per index (step-like), not a sampled signal. Each dimension is z-normalized globally.
Motifs. Motifs are repeated event sequences of variable subsequence length, m ≈ 10–100. There are several motif types per series, each with roughly 5–15 occurrences, which can sit back to back. Occurrences are often exact copies (distance ≈ 0) or near-copies with a few inserted, deleted or swapped events. The rest of T is non-repeating background.
Approach. A pan matrix profile computed by brute force: mstump for every m from min_m = 10 to max_m = 100, using the full-dimensional profile (all d dimensions). Exact repeats make every sub-window of a motif score 0, so raw distances can't rank across m. Instead, each P value is standardized against the profile of its own m. Motifs are then selected greedily from the best standardized value. Each one is expanded into a motif set at its own m (mmotifs-style, max_distance = max(mean − 2·std, min) of the distance profile, exclusion zone m/4), and overlapping occurrences are suppressed.
Problem. The loop stops after a fixed number of motifs (k, i.e. max_motifs), and the right k isn't known in advance. The current stand-in is the ground-truth number of occurrences, which isn't available in practice.
Question. What automated criterion should decide when to stop extracting motifs? Candidates we're considering:
Is there an established, ideally parameter-free, rule for this across window sizes? The Pan-Matrix-Profil paper puts this as an open / known problem.
Happy to clarify any open points. Summarized my problem with support of AI to align with Stumpy Library Terms.
-- Additional: Some Pseudo code --
T: (d, n) multi-dimensional time series
S = {}
for m in range(10, 101):
P, I = stumpy.mstump(T, m)
S[m] = zscore(P[-1]) # full-dim profile, standardized per m
motifs = []
for score, m, idx in sorted((S[m][i], m, i) for m in S for i in range(len(S[m]))):
if STOP(score, motifs): # ??? today: len(motifs) >= k
break
if not overlaps(idx, m, motifs):
motifs += motif_set(T, idx, m) # matches at m, max_distance = mean - 2*std
How to define STOP without knowing k?
All reactions