get_distance_function#

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

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

metric

Distance Function

‘dtw’

distance.dtw_distance

‘shape_dtw’

distance.shape_dtw_distance

‘ddtw’

distance.ddtw_distance

‘wdtw’

distance.wdtw_distance

‘wddtw’

distance.wddtw_distance

‘adtw’

distance.adtw_distance

‘erp’

distance.erp_distance

‘edr’

distance.edr_distance

‘msm’

distance.msm_distance

‘twe’

distance.twe_distance

‘lcss’

distance.lcss_distance

‘euclidean’

distance.euclidean_distance

‘squared’

distance.squared_distance

Parameters:
metricstr or Callable

The distance metric to use. If string given then it will be resolved to a alignment path function. If a callable is given, the value must be a function that accepts two numpy arrays and **kwargs returns a float.

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

The 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_distance_function
>>> import numpy as np
>>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> y = np.array([[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]])
>>> dtw_dist_func = get_distance_function("dtw")
>>> dtw_dist_func(x, y, window=0.2)
874.0