get_cost_matrix_function#

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

Get the cost matrix function for a given metric string or callable.

Parameters:
metric: str or Callable

The distance metric to use. The value must be one of the following strings: ‘dtw’, ‘ddtw’, ‘wdtw’, ‘wddtw’, ‘lcss’, ‘edr’, ‘erp’, ‘msm’ two time series.

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

The cost matrix function for the given metric.

Raises:
ValueError

If metric is not one of the supported strings or a callable. If the metric doesn’t have a cost matrix function.

Examples

>>> from aeon.distances import get_cost_matrix_function
>>> import numpy as np
>>> x = np.array([[1, 2, 3, 4, 5]])
>>> y = np.array([[11, 12, 13, 14, 15]])
>>> dtw_cost_matrix_func = get_cost_matrix_function("dtw")
>>> dtw_cost_matrix_func(x, y, window=0.2)
array([[100., 221.,  inf,  inf,  inf],
       [181., 200., 321.,  inf,  inf],
       [ inf, 262., 300., 421.,  inf],
       [ inf,  inf, 343., 400., 521.],
       [ inf,  inf,  inf, 424., 500.]])