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.
- 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’, ‘mpdist’ 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