# dtaidistance.dtw_barycenter

Dynamic Time Warping (DTW) Barycenter

author:

Wannes Meert

Copyright 2020-2022 KU Leuven, DTAI Research Group.

dtaidistance.dtw_barycenter.dba(s, c, mask=None, samples=None, use_c=False, nb_initial_samples=None, **kwargs)

DTW Barycenter Averaging.

F. Petitjean, A. Ketterlin, and P. Gan ̧carski. A global averaging method for dynamic time warping, with applications to clustering. Pattern Recognition, 44(3):678–693, 2011.

Parameters:
• s – Container of sequences

• c – Initial averaging sequence. If none is given, the first one is used (unless if nb_initial_samples is set). Better performance can be achieved by starting from an informed starting point (Petitjean et al. 2011).

• mask – Boolean array with the series in s to use. If None, use all.

• nb_initial_samples – If c is None, and this argument is not None, select nb_initial_samples samples and select the series closest to all other samples as c.

• use_c – Use a fast C implementation instead of a Python version.

• kwargs – Arguments for dtw.distance

Returns:

Bary-center of length len(c).

dtaidistance.dtw_barycenter.dba_loop(s, c=None, max_it=10, thr=0.001, mask=None, keep_averages=False, use_c=False, nb_initial_samples=None, nb_prob_samples=None, **kwargs)

Loop around the DTW Barycenter Averaging (DBA) method until convergence.

Parameters:
• s – Container of sequences

• c – Initial averaging sequence. If none is given, the first one is used (unless if nb_initial_samples is set). Better performance can be achieved by starting from an informed starting point (Petitjean et al. 2011).

• max_it – Maximal number of calls to DBA.

• thr – Convergence if the DBA is changing less than this value.

• mask – Boolean array with the series in s to use. If None, use all.

• keep_averages – Keep all DBA values (for visualisation or debugging).

• nb_initial_samples – If c is None, and this argument is not None, select nb_initial_samples samples and select the series closest to all other samples as c.

• nb_prob_samples – Probabilistically sample the best path instead of the deterministic version.

• use_c – Use a fast C implementation instead of a Python version.

• kwargs – Arguments for dtw.distance