I have a dataset with timestamps and event values (true or false -- these are based on sensor data which detect room occupancy). I'd like to build a model that would take a timestamp as an input and it would predict the following 24 hours of event data (1 event for every hour). Note that the signal shows a strong correlation with day of week and hour of day.

The inputs can be derived from the timestamp alone, so you can obtain attributes such as month, hour, minute, day of week as well as additional variables that, for example, may indicate a period of high activity (based on prior analysis).

The outputs have to be a sequence of event values (true/false or 1/0), 1 for each of the following 24 hours.

Note that unlike a time series problem, (1) the response variable is a class and (2) there may be a substantial gap between the last training point and new data for scoring (we don't actually receive the last N days of activity data before having to score a new data point). To treat this as a time series problem, I'd have to ignore month and year information and shift it back to the latest point in the data with matching hour of day and day of week, but this approach feels hacky.

The simple approach to tackle this problem would be to build 24 separate classification models, one for each prediction hour, but is there a better way?

In addition to the aforementioned set of classification models, I'm using a simple benchmark where I aggregate even rates over day of week and hour of day -- if the rate is above 50% at any point, I'd classify it as true, otherwise false.

I originally thought of using methods such as an LSTM neural network or a CRF model, however these approaches rely on a sequence of inputs to generate the next value in that sequence, whereas what I'm looking for is a model that could generate a sequence of outputs based on non-sequential data.

Perhaps there is another way to look at this problem. Perhaps there is no advantage in thinking of the response as a sequence. Either way, I look forward to hearing your suggestions.

Many thanks!

  • $\begingroup$ Knowledge, or a theory of, the nature of the events can be immensely helpful. Otherwise this question may be too abstract to have a definite answer. Could you provide that information? $\endgroup$ – whuber Dec 24 '18 at 22:28
  • $\begingroup$ @whuber thanks for your response, I've added this info, let me know if you'd like to learn more about the context $\endgroup$ – de1pher Dec 24 '18 at 22:30

You are not predicting 24 binary outcomes from single timestamp, but you have hourly, binary time-series and want to make predictions in 24h time horizon. So the binary outcomes are not only the labels to be predicted, but they are also the data. Just use some time-series forecasting method for binary data.

In your comments you gave us more details, that you have distant historical data, so you want to learn the time specific patterns and use them as predictions. The simplest solution would be just to take the conditional means of target variable aggregated by time, so basically something like AVG followed by GROUP BY in SQL. Since you may not have all the relevant data (all the combinations of days, hours, weeks etc.) and want to extrapolate, some machine learning approach may work better. I would start with simple models like logistic regressing or random forest with dummies for hour, weekday, month etc. as data.

  • $\begingroup$ Thanks for your response. As I said in my original post, I'm not sure if time series is the right approach here because there is going to be a substantial gap between the last training point and new data. To make this work, however, I could exploit the weekly pattern in the data and change the timestamp of any new data point such that it retains its original day of week and hour of day signature, but pretend that month and year follow directly after the last training data, but that feels hacky. $\endgroup$ – de1pher Dec 25 '18 at 8:53
  • $\begingroup$ @de1pher I still can't see why this isn't time-series problem for you. You assume changes over time that are auto-correlated. If you just want to use the weekly and hourly effects, this is still a time-series model with no tend, but only seasonal patterns. If you show us sample of your data, we can be more specific and it could be easier to understand the problem. $\endgroup$ – Tim Dec 25 '18 at 9:33
  • $\begingroup$ I'm afraid I cannot share the data. Time series might indeed be an effective approach here, I'm just saying that treating this as a time series problem isn't straightforward, because let's say the last training data point is 02/05/18 and I may need to predict data from 05/06/18 -- a typical time series problem would have to forecast the entire gap, not just the date of interest. $\endgroup$ – de1pher Dec 25 '18 at 9:54
  • 1
    $\begingroup$ @de1pher this is a time-series problem, the only problem is choice of model for it. $\endgroup$ – Tim Dec 25 '18 at 10:06
  • $\begingroup$ In that case how would you recommend to deal with (1) the gap between training and prediction data and (2) the binary nature of the response variable (perhaps a sequence model such as LSTM might handle this part sufficiently well) $\endgroup$ – de1pher Dec 25 '18 at 10:21

This is possible and there is a paper using discrete parameters as inputs and output continuous spatial distributions using LSTM. Spatial distribution is similar to time series. Hope this is helpful.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.