tslearn.barycenters.softdtw_barycenter(X, gamma=1.0, weights=None, method='L-BFGS-B', tol=0.001, max_iter=50, init=None)[source]

Compute barycenter (time series averaging) under the soft-DTW [1] geometry.

Soft-DTW was originally presented in [1].

X : array-like, shape=(n_ts, sz, d)

Time series dataset.

gamma: float

Regularization parameter. Lower is less smoothed (closer to true DTW).

weights: None or array

Weights of each X[i]. Must be the same size as len(X). If None, uniform weights are used.

method: string

Optimization method, passed to scipy.optimize.minimize. Default: L-BFGS.

tol: float

Tolerance of the method used.

max_iter: int

Maximum number of iterations.

init: array or None (default: None)

Initial barycenter to start from for the optimization process. If None, euclidean barycenter is used as a starting point.

numpy.array of shape (bsz, d) where bsz is the size of the init array if provided or sz otherwise

Soft-DTW barycenter of the provided time series dataset.


[1]M. Cuturi, M. Blondel “Soft-DTW: a Differentiable Loss Function for Time-Series,” ICML 2017.


>>> time_series = [[1, 2, 3, 4], [1, 2, 4, 5]]
>>> softdtw_barycenter(time_series, max_iter=5)
       [3.5101956 ],
>>> time_series = [[1, 2, 3, 4], [1, 2, 3, 4, 5]]
>>> softdtw_barycenter(time_series, max_iter=5)
       [1.8932251 ],

Examples using tslearn.barycenters.softdtw_barycenter