How to set window_size for dtw-python?

927 views Asked by At

I am trying out the different windowing options in dtw package detailed on this page: https://dynamictimewarping.github.io/py-api/html/api/dtw.dtw.html, hoping to see if I can reduce the time needed to run the dtw package.

When I entered

alignment = dtw(query_sample, ref_sample, keep_internals=True, window_type = "sakoechiba")

I got this error:

TypeError: sakoeChibaWindow() missing 1 required positional argument: 'window_size'

I then entered

alignment = dtw(query_sample, ref_sample, keep_internals=True, window_type = "sakoechiba", window_size = 5)

and got this error instead

TypeError: dtw() got an unexpected keyword argument 'window_size'

So where do I put the window_size argument? Appreciate your help, thank you.

2

There are 2 answers

0
Alessandro Davoli On

You can pass it as a dict within the "window_args" argument.

0
Brzoskwinia On

You must specify window_args and it can be done in two ways:

alignment = dtw(query_sample, ref_sample, keep_internals=True, 
                window_type= "sakoechiba", window_args= {"window_size": 7})

or

alignment = dtw(query_sample, ref_sample, keep_internals=True, 
                window_args= {"window_type": "sakoechiba", "window_size": 7})