# Next events prediction based on previous events

I have data set of sequences of user executed commands sorted in the order of its occurrence. The data looks like this.

• user1 : cmd1->cmd2->cmd3->...->cmdn
• user2 : cmd1->cmd2->cmd3->cmd5->...->cmdn
• user3 : cmd6->cmd2->cmd4->cmd5->...->cmdn

So the idea is to predict the next user command ordered by probability based on the previous command or sequence of commands similar to the clickstream prediction.

I have tried 1st-order Markov Chain but it is only based on previous command, and higher order Markov Chain would not be efficient because the sequences could be really long, with many different numbers of command.

Is there any other way to solve this kind of problem?