How to use the matrixprofile.distanceProfile.massDistanceProfile function in matrixprofile

To help you get started, we’ve selected a few matrixprofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github target / matrixprofile-ts / matrixprofile / motifs.py View on Github external
min_idx = mp_current.argmin()
        motif_distance = mp_current[min_idx]
        if motif_distance == np.inf:
            return motifs, distances
        if motif_distance == 0.0:
            motif_distance += np.finfo(mp_current.dtype).eps

        motif_set = set()
        initial_motif = [min_idx]
        pair_idx = int(mp[1][min_idx])
        if mp_current[pair_idx] != np.inf:
            initial_motif += [pair_idx]

        motif_set = set(initial_motif)

        prof, _ = distanceProfile.massDistanceProfile(ts, initial_motif[0], m)

        # kill off any indices around the initial motif pair since they are
        # trivial solutions
        for idx in initial_motif:
            _applyExclusionZone(prof, idx, ex_zone)
        # exclude previous motifs
        for ms in motifs:
            for idx in ms:
                _applyExclusionZone(prof, idx, ex_zone)

        # keep looking for the closest index to the current motif. Each
        # index found will have an exclusion zone applied as to remove
        # trivial solutions. This eventually exits when there's nothing
        # found within the radius distance.
        prof_idx_sort = prof.argsort()