# Choosing a distance metric and a clustering algorithm for time series

For every entity I have a corresponding time series which is built by a sliding window (win_size=7d, win_shift=3d, so we have overlapped windows)

With every win-shift, we count how many users are currently using the entity.

So we might see a time series that looks like this: $$[128, 105, 87, 20, 20, 20, 20, 20, 19, ...]$$

Or a time series that looks like this: $$[5, 5, 5, 5, 8, 6, 2, 1, 1, 1, 1, 1, 1, -1, -1, -1, ...]$$

Or $$[1, 1, 1, 1, 1, 1, 1, 1, ...]$$

(By the way, I padded with $$(-1)$$ to indicate that no information is available from that point and on)

I've encountered with some clustering algorithm that are dedicated for time series, and some time series similarity metrics like DTW.

I tried to use TimeSeriesKMeans with metric='dtw' but for some reason very "far" time series clustered together. I believe it has something to do with dtw which might be indifferent for the "intensity" of time the series? For the same reason, Pearson correlation might not be a good choice, right?

Also, should I normalize the time series? I thought about min-max normalization where max is global. What do you think?

EDIT:
Interestingly, increasing the number of clusters helped, but I still see weird stuff like $$[4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 3, 2, 3, 3, 4, 4, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 477, 477, 477, 477, 450]$$ is clustered with time series like $$[98, 96, 96, 95, 94, 94, 94, 94, 94, 94, 93, 93, 92, 89, 89, 89, 89, 89, 88, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 84, 84, 84, 84, 82, 82, 82, 82, 82, 82, 81, 81, 78, 77, 75, 73, 72]$$