What is Dynamic Time Warping?
hardAnswer
- Similarity between two sequences allowing non-linear alignment (stretch/compress).
- Finds the best matching via dynamic programming through a cost matrix.
- Robust to phase shifts and different lengths.
- Cost O(mn) per pair — expensive for large series .
- Standard for shape-based time-series similarity in speech, ECG, gesture recognition.
Check yourself — multiple choice
- Same as Euclidean
- DP alignment allowing stretch/compress → phase-shift-robust sequence distance; O(mn); window for scale
- Random
- Not real
DTW: dynamic-programming alignment; robust to phase shifts.
#clustering#similarity
Practise Unsupervised Learning
214 interview questions in this topic.
Related questions
- How do you cluster mixed numeric + categorical data?
- Why do you scale features before k-means?
- Cosine similarity vs Euclidean — when do you use cosine?
- You run k-means on customer data with age, income and number of purchases. What breaks?
- How does k-means work and what are its main limitations?
- How do you choose the number of clusters k?