Skip to content

Dba

polars_ts.clustering.dba

DTW Barycentric Averaging (DBA) for time series centroid computation.

Implements the iterative averaging algorithm from: Petitjean, F. et al. (2011). A global averaging method for dynamic time warping. Pattern Recognition.

_dtw_alignment_path(s, t)

Compute full DTW cost matrix and return the optimal alignment path.

dba(series, max_iter=30, tol=1e-05, init=None)

Compute the DTW Barycentric Average of a set of time series.

Parameters

series List of 1-D numpy arrays (may differ in length). max_iter Maximum number of refinement iterations. tol Convergence threshold on the mean absolute change. init Initial centroid estimate. If None, uses the medoid (series with minimum total DTW distance to all others).

Returns

np.ndarray The DBA centroid.

_medoid_init(series)

Pick the series with minimum total squared DTW distance as init.

_dba_update(centroid, series)

One DBA refinement step: align all series to centroid, average.