Back to models
Aligner

AlignerDTWfromDist

DistanceDistance-matrixUnequal length

Aligner interface for dtw-python using pairwise transformer.

Quickstart

python
from sktime.alignment.dtw_python import AlignerDTWfromDist

estimator = AlignerDTWfromDist(dist_trafo, step_pattern='symmetric2', window_type='none', window_size=None, open_begin=False, open_end=False)

Parameters(6)

dist_trafo: estimator following the pairwise transformer template
i.e., instance of concrete class implementing template BasePairwiseTransformer
step_patternstr, optional, default = “symmetric2”,
or dtw_python stepPattern object, optional step pattern to use in time warping, one of: ‘symmetric1’, ‘symmetric2’ (default), ‘asymmetric’, and dozens of other more non-standard step patterns; list can be displayed by calling help(stepPattern) in dtw
window_type: str, “none” (default), “itakura”, “sakoechiba”, “slantedband”, optional

the chosen windowing function

  • “none” (default) - no windowing

  • “sakoechiba” - a band around main diagonal

  • “slantedband” - a band around slanted diagonal

  • “itakura” - Itakura parallelogram

window_size: int, optional, default=None
size of the window if a windowing function is used if None and window_type=”sakoechiba”, defaults to 10% of series length
open_beginboolean, optional, default=False
open_end: boolean, optional, default=False
whether to perform open-ended alignments open_begin = whether alignment open ended at start (low index) open_end = whether alignment open ended at end (high index)

Examples

Basic usage example:
>>> import numpy as np
>>> import pandas as pd
>>> from sktime.alignment.dtw_python import AlignerDTWfromDist
>>> from sktime.dists_kernels import ScipyDist
>>> X = [
... pd. DataFrame ({ 'col1': np. random. randn (100)}),
... pd. DataFrame ({ 'col1': np. random. randn (100)})
... ]
>>> dist_trafo = ScipyDist ()
>>> aligner = AlignerDTWfromDist (dist_trafo = dist_trafo, step_pattern = 'symmetric2')
>>> aligner. fit (X) AlignerDTWfromDist(
... )
>>> alignment_df = aligner. get_alignment () Advanced usage example with custom distance transformation:
>>> dist_trafo_custom = ScipyDist(‘cityblock’)
>>> aligner_custom = AlignerDTWfromDist(… dist_trafo=dist_trafo_custom, … window_type=’sakoechiba’, … window_size=10, …)
>>> X_custom = [… pd.DataFrame({‘col1’: np.random.randn(200)}), … pd.DataFrame({‘col1’: np.random.randn(200)}) … ]
>>> aligner_custom.fit(X_custom) AlignerDTWfromDist(…)
>>> alignment_df_custom = aligner_custom.get_alignment()