0
$\begingroup$

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.

$\endgroup$

1 Answer 1

1
$\begingroup$

Are you sure you want to do clustering? It sounds like you need to find consensus motifs among the wifi box users. It is easy to find them, see [a]

[a] https://www.cs.ucr.edu/~eamonn/consensus_Motif_ICDM_Long_version.pdf

Why not cluster? By analogue with text, imagine you try to cluster {dfuCATnfkj, CATidsfas, oiDOGnb, saddsaDOG} You will not get meaningful clusters, but consensus motifs will give you {CAT, DOG}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.