Skip to content

.motifs no longer returning more than one motif #785

@waynedam

Description

@waynedam

I was finding this problem in my own work. Only one motif was being returned when there were at least two apparent in the time series.

I tried reproducing the example discussed in #438 where the motifs function properly returns multiple motifs but I find now it no longer does. I used the data provided in issue #438.

The csv file:
RoomA_CO2.csv

import csv
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [20, 6]  # width, height
plt.rcParams['xtick.direction'] = 'out'

co2 = []
with open('./RoomA_CO2.csv') as csvfile:
    reader = csv.DictReader(csvfile, delimiter=';')
    for row in reader:
        if len(row['CO2-Concentration (in ppm)'].strip()) > 0:
            co2.append(float(row['CO2-Concentration (in ppm)']))

m = 24
c = np.array(co2)
p = stumpy.stump(c, m)

dists, inde = stumpy.motifs(c, p[:, 0], max_motifs=2)

fig, axs = plt.subplots(2, sharex=True, gridspec_kw={'hspace': 0})
plt.suptitle('Motif (Pattern) Discovery', fontsize='30')
axs[0].plot(co2)
axs[0].set_ylabel('CO2 ppm', fontsize='20')

cols = ['red' , 'green', 'blue' ]

for z in range(0, inde.shape[0]):
    col = cols[z]
    start = inde[z, 0]
    stop = inde[z, 0] + m
    matches = stumpy.match(c[start:stop],c, max_distance=2.0)
    for mt in range(matches.shape[0]):
        s = matches[mt, 1]
        st = s + m
        axs[0].plot(np.arange(s, st), c[s : st], c=col)

axs[1].plot(p[:, 0])
axs[1].set_ylabel('Matrix profile', fontsize='20')
plt.show()

image

I understand the stumpy.match is not necessary but the stumpy.motifs only returns a single motif row.

inde.shape
(1,4)
inde
[39,179,77,223]

The fifth match in the plot around 125 is from the stumpy.matches.

I tried changing distance parameters, etc., but nothing seems to make a difference.

Has something changed in the version 1.11.1 stumpy.motifs that is not reflected in the documentation?
I noticed someone having an issue with stumpy.config.STUMPY_EXCL_ZONE_DENOM config in #780.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions