get_pairwise_distance_function#

get_pairwise_distance_function(metric: Union[str, Callable[[ndarray, ndarray, Any], ndarray]]) Callable[[ndarray, ndarray, Any], ndarray][source]#

Get the pairwise distance function for a given metric string or callable.

Parameters:
metric: str or Callable

The distance metric to use. If a string is given, the value must be one of the following strings: ‘euclidean’, ‘squared’, ‘dtw’, ‘ddtw’, ‘wdtw’, ‘wddtw’, ‘lcss’, ‘edr’, ‘erp’, ‘msm’ If a callable is given, the value must be a function that accepts two numpy arrays and **kwargs returns a np.ndarray that is the pairwise distance between each time series.

Returns:
Callable[[np.ndarray, np.ndarray, Any], np.ndarray]

The pairwise distance function for the given metric.

Raises:
ValueError

If metric is not one of the supported strings or a callable.

Examples

>>> from aeon.distances import get_pairwise_distance_function
>>> import numpy as np
>>> x = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y = np.array([[[11, 12, 13]],[[14, 15, 16]], [[17, 18, 19]]])
>>> dtw_pairwise_dist_func = get_pairwise_distance_function("dtw")
>>> dtw_pairwise_dist_func(x, y, window=0.2)
array([[300., 507., 768.],
       [147., 300., 507.],
       [ 48., 147., 300.]])