title: Machine Learning Algorithm for Predicting Order of Events?
body: <p>Simple machine learning question. Probably numerous ways to solve this:</p>
  
  <p>There is an <strong>infinite</strong> stream of  4 possible events:</p>
  
  <p><code>'event_1', 'event_2', 'event_4', 'event_4'</code></p>
  
  <p>The events do not come in in completely random order. We will assume that there are some complex patterns to the order that most events come in, and the rest of the events are just random. We do not know the patterns ahead of time though.</p>
  
  <p>After each event is received, I want to predict what the next event will be based on the order that events have come in in the past. So my question is: <strong>What machine learning algorithm should I use for this predictor?</strong></p>
  
  <p>The predictor will then be told what the next event actually was:</p>
  
  <pre><code>Predictor=new_predictor()
  
  prev_event=False
  while True:
      event=get_event()
      if prev_event is not False:
          Predictor.last_event_was(prev_event)
      predicted_event=Predictor.predict_next_event(event)
  </code></pre>
  
  <p>The question arises of how long of a history that the predictor should maintain, since maintaining infinite history will not be possible. I'll leave this up to you to answer. The answer can't be infinte though for practicality.</p>
  
  <p>So I believe that the predictions will have to be done with some kind of rolling history. Adding a new event and expiring an old event should therefore be rather efficient, and not require rebuilding the entire predictor model, for example.</p>
  
  <p>Specific code, instead of research papers, would add for me <strong>immense value</strong> to your responses. Python or C libraries are nice, but anything will do.</p>
  
  <p><strong>Update:</strong> And what if more than one event can happen simultaneously on each round. Does that change the solution?</p>