MCPcopy Index your code
hub / github.com/stumpy-dev/stumpy / _rea

Function _rea

stumpy/floss.py:184–229  ·  view source on GitHub ↗

Find the location of the regimes using the regime extracting algorithm (REA) Parameters ---------- cac : numpy.ndarray The corrected arc curve n_regimes : int The number of regimes to search for. This is one more than the number of regime changes as

(cac, n_regimes, L, excl_factor=5)

Source from the content-addressed store, hash-verified

182
183
184def _rea(cac, n_regimes, L, excl_factor=5):
185 """
186 Find the location of the regimes using the regime extracting
187 algorithm (REA)
188
189 Parameters
190 ----------
191 cac : numpy.ndarray
192 The corrected arc curve
193
194 n_regimes : int
195 The number of regimes to search for. This is one more than the
196 number of regime changes as denoted in the original paper.
197
198 L : int
199 The subsequence length that is set roughly to be one period length.
200 This is likely to be the same value as the window size, `m`, used
201 to compute the matrix profile and matrix profile index but it can
202 be different since this is only used to manage edge effects
203 and has no bearing on any of the IAC or CAC core calculations.
204
205 excl_factor : int, default 5
206 The multiplying factor for the regime exclusion zone
207
208 Returns
209 -------
210 regime_locs : numpy.ndarray
211 The locations of the regimes
212
213 Notes
214 -----
215 DOI: 10.1109/ICDM.2017.21 <https://www.cs.ucr.edu/~eamonn/Segmentation_ICDM.pdf>`__
216
217 See Table II
218
219 This is the implementation for the regime extracting algorithm (REA).
220 """
221 regime_locs = np.empty(n_regimes - 1, dtype=np.int64)
222 tmp_cac = copy.deepcopy(cac)
223 for i in range(n_regimes - 1):
224 regime_locs[i] = np.argmin(tmp_cac)
225 excl_start = max(regime_locs[i] - excl_factor * L, 0)
226 excl_stop = min(regime_locs[i] + excl_factor * L, cac.shape[0])
227 tmp_cac[excl_start:excl_stop] = 1.0
228
229 return regime_locs
230
231
232def fluss(I, L, n_regimes, excl_factor=5, custom_iac=None):

Callers 2

test_reaFunction · 0.90
flussFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_reaFunction · 0.72