Next, however, I want to introduce another model, which uses a completely different algorithm. This algorithm is called dynamic time warping. What it does is give you a metric that represents the similarity between two time series:
- To get started, we'll need to pip install the fastdtw library:
!pip install fastdtw
- Once that is installed, we'll import the additional libraries we'll need:
from scipy.spatial.distance import euclidean from fastdtw import fastdtw
- Next, we'll create the function that will take in two series and return the distance between them:
def dtw_dist(x, y): distance, path = fastdtw(x, y, dist=euclidean) return distance
- Now, we'll split our 18 years' worth of time series data into distinct five-day ...