dtw-python icon indicating copy to clipboard operation
dtw-python copied to clipboard

Finding multiple matches

Open tommedema opened this issue 3 years ago • 1 comments

I'm trying to find the closest matches to a query graph of length 100 in a much longer time series of 100000 length. I'd like it to return all matches with a normalizedDistance < X. How would I do this?

This is what I have so far:

from dtw import *
import numpy as np
import matplotlib.pyplot as plt

data = np.cumsum(np.random.uniform(-0.5, 0.5, 1000000))
query = np.cumsum(np.random.uniform(-0.5, 0.5, 100))

alignment = dtw(query, data, window_type='sakoechiba', window_args={'window_size': 10}, step_pattern="asymmetricP05", open_begin=True, open_end=True)

print(alignment.normalizedDistance) # 0.8975468634096962

It works but it only returns a single result. How do I return all matches with a normalizedDistance < X?

tommedema avatar Aug 06 '22 08:08 tommedema

Not trivial but should be available in the next major release. In the meantime, as a possible workaround, consider repeating the alignment multiple times with several subsets (possibly overlapping) of the data.

tonigi avatar Aug 06 '22 09:08 tonigi