rules/tslearn/kmeans-metric-params-mismatch.md
TimeSeriesKMeans defaults to metric="euclidean", where metric_params is never passed to scipy.spatial.distance.cdist. When metric="dtw", forwarding metric_params={"gamma": ...} raises TypeError: _cdist_dtw() got an unexpected keyword argument 'gamma' because gamma is only accepted by metric="softdtw".
diff
| 1 | -km = TimeSeriesKMeans(n_clusters=3, metric="dtw", metric_params={"gamma": 0.5}, random_state=0) |
| 2 | +km = TimeSeriesKMeans(n_clusters=3, metric="softdtw", metric_params={"gamma": 0.5}, random_state=0) |
What the rule reports
TimeSeriesKMeans(...) calls that pass metric_params={"gamma": ...} with metric="dtw", or pass a non-None metric_params while metric is "euclidean" or omitted.
How to fix it
Set metric="softdtw" when configuring gamma, set metric="dtw" when passing DTW constraint keys (global_constraint, sakoe_chiba_radius, itakura_max_slope), or remove metric_params for Euclidean k-means.