Find the top motifs for time series `T`. A subsequence, `Q`, becomes a candidate motif if there are at least `min_neighbor` number of other subsequence matches in `T` (outside the exclusion zone) with a distance less or equal to `max_distance`. Parameters ---------- T
(
T,
P,
M_T,
Σ_T,
T_subseq_isconstant,
excl_zone,
min_neighbors,
max_distance,
cutoff,
max_matches,
max_motifs,
atol=1e-8,
)
| 11 | |
| 12 | |
| 13 | def _motifs( |
| 14 | T, |
| 15 | P, |
| 16 | M_T, |
| 17 | Σ_T, |
| 18 | T_subseq_isconstant, |
| 19 | excl_zone, |
| 20 | min_neighbors, |
| 21 | max_distance, |
| 22 | cutoff, |
| 23 | max_matches, |
| 24 | max_motifs, |
| 25 | atol=1e-8, |
| 26 | ): |
| 27 | """ |
| 28 | Find the top motifs for time series `T`. |
| 29 | |
| 30 | A subsequence, `Q`, becomes a candidate motif if there are at least `min_neighbor` |
| 31 | number of other subsequence matches in `T` (outside the exclusion zone) with a |
| 32 | distance less or equal to `max_distance`. |
| 33 | |
| 34 | Parameters |
| 35 | ---------- |
| 36 | T : numpy.ndarray |
| 37 | The time series or sequence |
| 38 | |
| 39 | P : numpy.ndarray |
| 40 | Matrix Profile of time series, `T` |
| 41 | |
| 42 | M_T : numpy.ndarray |
| 43 | Sliding mean of time series, `T` |
| 44 | |
| 45 | Σ_T : numpy.ndarray |
| 46 | Sliding standard deviation of time series, `T` |
| 47 | |
| 48 | T_subseq_isconstant : numpy.ndarray |
| 49 | A boolean array that indicates whether a subsequence in `T` is constant (True) |
| 50 | |
| 51 | excl_zone : int |
| 52 | Size of the exclusion zone |
| 53 | |
| 54 | min_neighbors : int |
| 55 | The minimum number of similar matches a subsequence needs to have in order |
| 56 | to be considered a motif. |
| 57 | |
| 58 | max_distance : float or function |
| 59 | For a candidate motif, `Q`, and a non-trivial subsequence, `S`, `max_distance` |
| 60 | is the maximum distance allowed between `Q` and `S` so that `S` is considered |
| 61 | a match of `Q`. If `max_distance` is a function, then it must be a function |
| 62 | that accepts a single parameter, `D`, in its function signature, which is the |
| 63 | distance profile between `Q` and `T`. |
| 64 | |
| 65 | cutoff : float |
| 66 | The largest matrix profile value (distance) that a candidate motif is allowed |
| 67 | to have. |
| 68 | |
| 69 | max_matches : int |
| 70 | The maximum number of similar matches to be returned. The resulting |