# ML technique to predict next online

I want a direction for ML technique to predict the next time you will be online in chat app

My table contains; user id, timestamp & status

status is a categorical variable (online, composing, offline), I'm saving a row for each status change which means user online, maybe writes something to me (composing) and afterwards went offline, so I can extract the time online (currently I don't see a reason for this feature)

• I want to export the model to PMML

What is the best approach if I want to a service to get the next timestamp that user will be online ?

• Whoever keeps downvoting posts but not commenting, stoooooooop! Please post a reason for the downvote. Commented Apr 13, 2017 at 15:07

## 3 Answers

That sounds like time series forecasting. Here's a related post:

https://stats.stackexchange.com/questions/212912/forecast-time-series-data-with-external-variables

If you are able to use python at all, I'd look into using a recurrent neural network variant such as LSTM or GRU to forecast their future timestamps.

Chris Olah wrote a really nice blog post on LSTM / Recurrent nets http://colah.github.io/posts/2015-08-Understanding-LSTMs/

Using the python library Keras, it is actually very easy to code an LSTM network. The general "Sequential" model (most straighforward / basic model type) is described here: https://keras.io/getting-started/sequential-model-guide/ Your model could be made through the sequential model type, using recurrent layers instead of Dense ones. The only thing is your inputs need to be shaped correctly, so you'll be dealing with a 3D tensor (3d numpy array) for the time series input, where [N,T,K] is the shape of the tensor: N= # of samples, T = # of timesteps in the input and K = # of variables. You will probably have to zero pad / mask the timesteps for uneven sequences as well, which is fairly easy to do.

Recurrent / LSTM / GRU layers in Keras are described on this page: https://keras.io/layers/recurrent/

Best of luck!

If this is too much then I guess you can just work with time series models. But reccurrent nets have been known to perform incredibly with an array of temporal problems / prediction.

I agree with the two answers above me!

This is a time series forecasting problem.

Python with tensorflow and keras would be the best route to build the model and have it able to be exported to train somewhere else.

Start off with something nice and simple, if it doesn't do what you want add some more layers, tinker with the learning rate, etc.

Here is a link very similar to what you want to do: Tutorial

Hope that helped! Enjoy building it, this stuff is a lot of fun!!