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

Function _cac

stumpy/floss.py:119–181  ·  view source on GitHub ↗

Compute the corrected arc curve (CAC) Parameters ---------- I : numpy.ndarray The matrix profile indices for the time series of interest L : int The subsequence length that is set roughly to be one period length. This is likely to be the same value as t

(I, L, bidirectional=True, excl_factor=5, custom_iac=None, seed=0)

Source from the content-addressed store, hash-verified

117
118
119def _cac(I, L, bidirectional=True, excl_factor=5, custom_iac=None, seed=0):
120 """
121 Compute the corrected arc curve (CAC)
122
123 Parameters
124 ----------
125 I : numpy.ndarray
126 The matrix profile indices for the time series of interest
127
128 L : int
129 The subsequence length that is set roughly to be one period length.
130 This is likely to be the same value as the window size, `m`, used
131 to compute the matrix profile and matrix profile index but it can
132 be different since this is only used to manage edge effects
133 and has no bearing on any of the IAC or CAC core calculations.
134
135 bidirectional : bool, default True
136 Flag for normalizing the arc curve with a bidirectional (`True`) or
137 1-dimensional (`False`) idealized arc curve. If a `custom_iac` is
138 specified then this flag is ignored.
139
140 excl_factor : int, default 5
141 The multiplying factor for the first and last regime exclusion zones
142
143 custom_iac : numpy.ndarray, default None
144 A custom idealized arc curve (IAC) that will used for correcting the
145 arc curve
146
147 seed : int, default 0
148 NumPy random seed used in sampling the `iac` beta distribution. Set this
149 to your desired value for reproducibility purposes. The default value is
150 set to `0`.
151
152 Returns
153 -------
154 output : numpy.ndarray
155 A corrected arc curve (CAC)
156
157 Notes
158 -----
159 DOI: 10.1109/ICDM.2017.21 <https://www.cs.ucr.edu/~eamonn/Segmentation_ICDM.pdf>`__
160
161 See Table I
162
163 This is the implementation for the corrected arc curve (CAC).
164 """
165 k = I.shape[0]
166 AC = _nnmark(I)
167 CAC = np.zeros(k, dtype=np.float64)
168
169 if custom_iac is None:
170 IAC = _iac(k, bidirectional, seed=seed)
171 else:
172 IAC = custom_iac
173 IAC[IAC == 0.0] = 10**-10 # Avoid divide by zero
174 CAC[:] = AC / IAC
175 CAC[CAC > 1.0] = 1.0 # Equivalent to min
176

Callers 9

test_cacFunction · 0.90
test_cac_custom_iacFunction · 0.90
test_flossFunction · 0.90
test_aamp_flossFunction · 0.90
test_floss_inf_nanFunction · 0.90
test_aamp_floss_inf_nanFunction · 0.90
flussFunction · 0.85
updateMethod · 0.85

Calls 2

_nnmarkFunction · 0.85
_iacFunction · 0.85

Tested by 7

test_cacFunction · 0.72
test_cac_custom_iacFunction · 0.72
test_flossFunction · 0.72
test_aamp_flossFunction · 0.72
test_floss_inf_nanFunction · 0.72
test_aamp_floss_inf_nanFunction · 0.72