MCPcopy
hub / github.com/stumpy-dev/stumpy / _nnmark

Function _nnmark

stumpy/floss.py:13–47  ·  view source on GitHub ↗

Count the number of nearest neighbor overhead crossings or arcs. Parameters ---------- I : numpy.ndarray Matrix profile indices Returns ------- nnmark : numpy.ndarray Counts of nearest neighbor overheard crossings or arcs. Notes ----- DOI:

(I)

Source from the content-addressed store, hash-verified

11
12
13def _nnmark(I):
14 """
15 Count the number of nearest neighbor overhead crossings or arcs.
16
17 Parameters
18 ----------
19 I : numpy.ndarray
20 Matrix profile indices
21
22 Returns
23 -------
24 nnmark : numpy.ndarray
25 Counts of nearest neighbor overheard crossings or arcs.
26
27 Notes
28 -----
29 DOI: 10.1109/ICDM.2017.21 <https://www.cs.ucr.edu/~eamonn/Segmentation_ICDM.pdf>`__
30
31 See Table I
32
33 This is a fast and vectorized implementation of the nnmark algorithm.
34 """
35 I = I.astype(np.int64)
36
37 # Replace index values that are less than zero with its own positional index
38 idx = np.argwhere(I < 0).flatten()
39 I[idx] = idx
40
41 k = I.shape[0]
42 i = np.arange(k, dtype=np.int64)
43
44 nnmark = np.bincount(np.minimum(i, I), minlength=k)
45 nnmark -= np.bincount(np.maximum(i, I), minlength=k)
46
47 return nnmark.cumsum()
48
49
50def _iac(

Callers 3

test_nnmarkFunction · 0.90
_iacFunction · 0.85
_cacFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_nnmarkFunction · 0.72