I'm working on classifying times series to find clear pattern of use. My data is collected from clients of a telecom company, and we want to detect pattern of the amount of data consumed by clients with their wifi box. So each client have a time series of how much data he consumed each 6minutes (I resampled it to hours).
So i created a python dictionary where keys
are mac adresses of clients and values
are times series as lists, so i have a dictionary of times series for all clients.
I also applied DTW with KmeansTimeSeries
using tslearn
:
km = TimeSeriesKMeans(n_clusters = cluster_count, metric="dtw", verbose=1)
labels = km.fit_predict(mySeries)
But i always get this error :
ValueError: Expected 2D array, got scalar array instead: array={'02:0F:B5:10:96': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], '02:0F:B5:E6:1A': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], '02:0F:B5:FF:0A': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],............ Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
You can see now how my dictionary looks like(the first time series contain a lot of zeros).
The clustering works if i used just a 2D numpy array with all my times series in it, instead of a dictionary with all the keys of different clients, but i need to keep the keys to be able to identify clients after the clustering.