Time series distances/kernels#

The sktime.dists_kernels module contains pairwise transformers, such as distances and kernel functions on time series data. It also contains some distances/kernel functions for tabular data.

Distances and kernel functions are treated the same, as they have the same formal signature - that of a “pairwise transformer”.

Below, we list separately pairwise transformers for time series, and pairwise transformers for tabular data.

All time series distances and kernels in sktime can be listed using the sktime.registry.all_estimators utility, using estimator_types="transformer-pairwise-panel", optionally filtered by tags. Valid tags can be listed using sktime.registry.all_tags.

Distances and kernels for vector-valued features can be listed using estimator_types="transformer-pairwise".

Standalone, performant numba distance functions are available in the sktime.distance module. These are not wrapped in the sktime BaseObject interface and can therefore be used within other numba compiled functions for end-to-end compilation.

Time series distances/kernels#

Distances or kernels between time series, following the pairwise panel transformer interface of BasePairwiseTransformerPanel.

Composition#

PwTrafoPanelPipeline(pw_trafo, transformers)

Pipeline of transformers and a pairwise panel transformer.

CombinedDistance(pw_trafos[, operation])

Distances combined via arithmetic operation, e.g., addition, multiplication.

IndepDist(dist[, aggfun])

Variable-wise aggregate of multivariate kernel or distance function.

AggrDist(transformer[, aggfunc, aggfunc_is_symm])

Panel distance from tabular distance aggregation.

FlatDist(transformer)

Panel distance or kernel from applying tabular trafo to flattened time series.

DistFromAligner([aligner])

Distance transformer from aligner.

KernelFromDist(dist[, dist_diag])

Kernel function obtained from a distance function.

DistFromKernel(kernel)

Distance function obtained from a kernel function.

Simple Time Series Distances#

Simple time series distance, including flat/vector distance, bag-of-value distance, or mean pairwise distance can be obtained by applying AggrDist or FlatDist to pairwise distances in ScipyDist. See docstring of AggrDist and FlatDist.

AggrDist(transformer[, aggfunc, aggfunc_is_symm])

Panel distance from tabular distance aggregation.

FlatDist(transformer)

Panel distance or kernel from applying tabular trafo to flattened time series.

Dynamic Time Warping Distances#

DtwDist([weighted, derivative, window, ...])

Interface to sktime native dtw distances, with derivative or weighting.

DtwPythonDist([dist, step_pattern, ...])

Interface to dynamic time warping distances in the dtw-python package.

DtwDistTslearn([global_constraint, ...])

Dynamic time warping distance, from tslearn.

SoftDtwDistTslearn([normalized, gamma])

Soft dynamic time warping distance, from tslearn.

CtwDistTslearn([max_iter, n_components, ...])

Canonical time warping distance, from tslearn.

LuckyDtwDist([window])

Lucky dynamic time warping distance.

Time warping distances can also be obtained by composing DistFromAligner with a time warping aligner, see docstring of DistFromAligner:

DistFromAligner([aligner])

Distance transformer from aligner.

Edit Distances#

EditDist([distance, window, ...])

Interface to sktime native edit distances.

LcssTslearn([eps, global_constraint, ...])

Longest Common Subsequence similarity distance, from tslearn.

Time Series Kernels#

Simple time series kernels, including flat/vector kernels, bag-of-value kernels, or mean pairwise kernels can be obtained by applying AggrDist or FlatDist to kernels from sklearn.gaussian_process.kernels. See docstring of AggrDist and FlatDist.

AggrDist(transformer[, aggfunc, aggfunc_is_symm])

Panel distance from tabular distance aggregation.

FlatDist(transformer)

Panel distance or kernel from applying tabular trafo to flattened time series.

Advanced time series kernels that cannot be expressed as aggregates or flat applicates:

GAKernel([sigma, n_jobs, verbose])

Global Alignment Kernel, from tslearn.

SignatureKernel([kernel, level, degree, ...])

Time series signature kernel, including high-order and low-rank variants.

Base class#

BasePairwiseTransformerPanel()

Base pairwise transformer for panel data template class.

Tabular distances/kernels#

Distances or kernels between tabular vectors or data frame rows, following the pairwise transformer interface of BasePairwiseTransformer.

Distance metrics from scipy#

ScipyDist([metric, p, colalign, ...])

Interface to scipy distances.

Base class#

BasePairwiseTransformer()

Base pairwise transformer for tabular or series data template class.

Standalone numba distances#

Standalong functions not wrapped in the sktime BaseObject interface. Can be used within other numba compiled functions for end-to-end compilation.

ddtw_distance(x, y[, window, ...])

Compute the derivative dynamic time warping (DDTW) distance between time series.

dtw_distance(x, y[, window, ...])

Compute the dynamic time warping (DTW) distance between two time series.

edr_distance(x, y[, window, ...])

Compute the Edit distance for real sequences (EDR) between two series.

erp_distance(x, y[, window, ...])

Compute the Edit distance for real penalty (ERP) distance between two series.

euclidean_distance(x, y, **kwargs)

Compute the Euclidean distance between two time series.

lcss_distance(x, y[, window, ...])

Compute the longest common subsequence (LCSS) score between two time series.

msm_distance(x, y[, c, window, ...])

Compute the move-split-merge distance.

pairwise_distance(x[, y, metric])

Compute the pairwise distance matrix between two time series.

squared_distance(x, y, **kwargs)

Compute the squared distance between two time series.

twe_distance(x, y[, window, ...])

Time Warp Edit (TWE) distance between two time series.

wddtw_distance(x, y[, window, ...])

Compute the weighted derivative dynamic time warping (WDDTW) distance.

wdtw_distance(x, y[, window, ...])

Compute the weighted dynamic time warping (WDTW) distance between time series.