# Are there any python libraries for sequences clustering?

I have a problem which I explained in other question. I've understood that my dataset is a sequence of states or something like that. Is there libraries to analyze sequence with python? And is it right way to use Hidden Markov Models to cluster sequences?

• This may help. Moreover, markov hidden models are those that your current state does not have a long connection to the far previous states. I guess you need LSTM-like classifiers rather than simple rnns for classification-like tasks. Apr 3 '18 at 10:14
• I'm learning more about LSTM and RNN at the moment. Is it possible to use LSTM RNN with unsupervised data? And which tools may be useful? tensorflow.org/tutorials/recurrent - is it ok to try use with my dataset? Apr 3 '18 at 10:28

Is there libraries to analyze sequence with python

You can take a look at here. You can also use TensorFlow if your task is sequence classification, but based on comments you have referred that your task is unsupervised. Actually, LSTMs can be used for unsupervised tasks too depending on what you want. Take a look at here.

And is it right way to use Hidden Markov Models to cluster sequences?

Markov hidden models are those that your current state does not depend on all previous states. If you your task has longterm dependencies, you can use LSTM networks. If your data does not have longterm dependencies you can use simple RNNs.

• Thanks for your answer! I've tried one approach from this topic: stats.stackexchange.com/questions/337439/… andI got the following results: " Clusters distinguish from each other by their classes, but not by the nature of changing. I mean cluster #1 consists of sequences with classes 1 in the end and etc. But I'm trying to distinguish them by their behavior, in other words cluster1 consists of customers who has started buying other class of products. Cluster2 consists of customers who keeps buying similar class of products and etc." Apr 3 '18 at 12:19
• Maybe the description above of the results helps you to understand my problem. After this explanation RNN will be the right way? How do you think? Apr 3 '18 at 12:22
• @Andrey Do you want to have prediction why they are going to buy next? Apr 4 '18 at 11:03
• Before predicting I'm going to analyze customers behavior and their preferences. To examine different clusters of sequences of their orders. For example some of them prefer meat meals but sometimes try meals with chicken. Or identify customers who have absolutely changed their preferences. Apr 5 '18 at 7:21
• @Andrey Take a look at professor Andrew Ng course of deep learning specialization, the fifth course. The first week he explains the use of LSTMs for sequence generation. That may help you. Apr 8 '18 at 3:55