Closed dmehrab06 closed 2 years ago
It appears you want the Needleman-Wunsch algorithm instead of DTW. They are similar but NW takes any type of symbol and DTW only numerical inputs. See https://dtaidistance.readthedocs.io/en/latest/usage/sequence.html . In this toolbox, there is only a Python implementation for NW because it's very flexible (e.g. the substitution cost can be customized), so it's not particular fast.
Is it possible two calculate the DTW distance by other distance metric than euclidean. For example: I have two time series sequence of strings as follows:
a = ['rain', 'sunny', 'rain', 'cloudy']
b = ['sunny', 'rain', 'rain', 'cloudy']
I can convert them to numpy array by enumerating the strings: (rain = 0, sunny = 1, cloudy = 2)
a = [0,1,0,2]
b = [1,0,0,2]
The way I want to interpret this is if two elements are same, the distance is 0; otherwise the distance is 1. So, the difference between 0--1, the difference between 1--2 and the difference between 0--2 all should be the same.