Python: Dynamic Time Warping, what actually is a 'similarity score' and how to compute it? I want to compare two time-series data to see their similarity to each other.
For this task, I use Dynamic Time Warping (DTW) algorithm. I have tried the implementation using Python tslearn: (the docs is here)
import tslearn.metrics
import numpy as np

s1 = [0, 0, 0, 0, 0, 0, 52, 50.144, 50.144, 50.144, 50, 51.1544, 50.284, 49.214, 48.5248] # sequence 1
s2 = [0, 0, 0, 0, 0, 0, 52.9304, 51.144, 50.144, 51.144, 50.1544, 51.1544, 49.2184, 49.2184, 49.5248] # sequence 2

a = tslearn.metrics.cdist_dtw(s1, s2) # Cross similarity matrix between time series datasets
b = tslearn.metrics.dtw_path(s1, s2) # Get both the matching path and the similarity score for DTW
c = tslearn.metrics.dtw(s1, s2) # Get only the similarity score for DTW
print(&quot;Similarity: &quot;, a)
print(&quot;*&quot;*127)
print(&quot;Path and Similarity: &quot;, b)
print(&quot;*&quot;*127)
print(&quot;DTW Similarity: &quot;, c)
print(&quot;*&quot;*127)

I got this result:
Similarity:  [[1.84218766]]
*********************************************************************************************************
Path and Similarity:  ([(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (6, 7), (7, 8), (8, 8), (9, 8), (10, 8), (11, 9), (12, 10), (12, 11), (13, 12), (13, 13), (14, 14)], 1.8421876560220476)
*********************************************************************************************************
DTW Similarity:  1.8421876560220476
*********************************************************************************************************

What confuse me here is the term similarity used in the library. I am not able to get any satisfactory explanation from the docs, so I am currently confused.
When I compare 2 exact same sequence, for example:
s1 = [0, 0, 0, 0, 0, 0, 52, 50.144, 50.144, 50.144, 50, 51.1544, 50.284, 49.214, 48.5248] 
s2 = [0, 0, 0, 0, 0, 0, 52, 50.144, 50.144, 50.144, 50, 51.1544, 50.284, 49.214, 48.5248]

the similarity score (variable a, b, c) would result in 0.
My question:

If 0 means my 2 sequences are similar, why is the library using the term 'similarity', not 'disimilarity'? Am I confusing myself with those 2 terms? Is similarity here has the same meaning as distance?

How does tslearn compute the similarity score?
You have got exactly what you requested in your code.

DTW is a similarity measure between time series. By default, tslearn
uses squared Euclidean distance as the base metric (I am citing the
documentation).

Another ground metric can be used, when specified in the code.
You use a default, i.e., Euclidean-distance metric, your sequences (time series), $s1$ and $s2$, are aligned $len(s1) = len(s2)$. The Euclidean distance is a square root of sum of squared differences of sequence items: $DTW_{Euclid}(s1,s2) = \sqrt{\sum_k(s1[k]-s2[k])^2}$. For identical sequences you have: $DTW_{Euclid}(s1,s1) = \sqrt{\sum_k(s1[k]-s1[k])^2} = 0$. The idea of similarity as the qualitative degree, when referring this Python ecosystem's feature, is supplanted by the concept of distance metric, although the word remains. You have no other choice as to accommodate yourself to this word usage.
This is how tslearn computes the &quot;similarity&quot; when you use a default metric. For other metrics and unaligned sequences, consult the documentation. The portal dsp.SE is ready to assist you in the case of uncertainty.