Pairwise and paired distance#

In this example we explore the pairwise_distance and paired_distance functions which can be used to compute the distance between time series.

[1]:
from wildboar.datasets import load_dataset
from wildboar.distance import pairwise_distance, paired_distance

First, we load a dataset.

[2]:
x, _ = load_dataset("GunPoint")

Next, we compute the euclidean distance (this is the default metric) between the three first time series.

[3]:
pairwise_distance(x[0:3], x[0:3])
[3]:
array([[0.        , 4.62126068, 4.84338669],
       [4.62126068, 0.        , 2.4905868 ],
       [4.84338669, 2.4905868 , 0.        ]])

We can also compute the distance between two samples. Note that the output changes depending on input. Also note that we compute the derivative dynamic time warping distance.

[4]:
pairwise_distance(x[0], x[1], metric="ddtw", metric_params={"r": 0.5})
[4]:
0.19191544750651415

Finally, we compute the distance between the samples.

[5]:
paired_distance(x[0:3], x[1:4], metric="dtw", metric_params={"r": 0.5})
[5]:
array([0.43268507, 1.31648328, 0.49386735])