# Clustering/ Classifying users based on sequence of action and time

I have some user data where each user has a certain pattern of being at different places for some time. I would like to create a model which will cluster/classify these users based on these patterns and the time spent at each place. So suppose user patterns are like:

Place_1(60 min)- Place_2(30 min)- Place_5(45 min)- user 1 -label(1)

Place_1(60 min)- Place_2(60 min)- Place_5(45 min)- user 2 -label(2)

Place_1(60 min)- Place_2(60 min)- Place_5(40 min)- user 3 -label(2)

Place_2(60 min)- Place_1(60 min)- Place_5(45 min)- user 4 -label(3)

Place_2(60 min)- Place_1(60 min)- Place_5(45 min)- user 5 -label(3)


They should be clustered/classified as:

1- User 1

2- User 2, User 3

3- User 4, User 5


The time duration is continuous. Also, I already have labels for these patterns so I can do classification as well as clustering. I initially thought of doing kmeans clustering on these patterns, but introducing the duration of stay at each place is messing the clustering up. I am currently using a random forest classifier, but the results are not as promising. Any help would be highly appreciated.

• You could use RNN auto-encoder, hence you could use embedding layer to transform the categorical place input into a continuous dense vector, If you want to do classification just use RNN and augment the last hidden state with a linear classifier May 18 '18 at 17:32
• Thanks, I was refraining from using neural network for this. My stack currently involves spark mllib with scala for implementing the model. I am not limiting myself to it and is certainly open to moving to neural network if thats the only plausible option. May 18 '18 at 18:41
• if you are encoding(places as columns; time data in rows) your data properly, i don't see any problem with k means as well as randomforest. elaborate more on your problem May 18 '18 at 20:09
• Can you please tell me what you mean by places in column and time data in column. Currently I have user record as a row where the sequence of places and time spent at the place is maintained. I cant have a concept of places with fixed column as they can come up in any order for each user. May 20 '18 at 20:11