I have a fairly simple dataset of energy consumption values generated every half hour. I want to train a model to predict the energy consumption at a particular time.

enter image description here

How do I model time values?


2 Answers 2


At first sight, the total acumulated energy consumption seems to have a linear relation with time, so I suggest to try a linear regression at first. There are several libraries you can use to code it. I recommend you do it with pandas and sklearn, here is an answer related to this: answer.

If the relation is not linear, so I could try with a more complex model (but I suggest to keep simplicity at first). Since you are trying to predict a temporal serie, I would try with an LSTM model. Here is a tutorial to implement an LSTM neural network with keras.

  • $\begingroup$ The problem is not about linearity or non-linearity, if we formulate the input as the current timestep and the k-previous timesteps concatenated into one feature vector, a standard NN will have separate parameters for each input feature, so it would need to learn all of the rules of the problem separately at each position in the sequence. By comparison, a recurrent neural network shares the same weights across several time steps. $\endgroup$ May 11, 2018 at 18:06
  • $\begingroup$ I understand the difference between a standard and a recurrent neural network, but I think the first approach to model the problem should be the simplest. $\endgroup$ May 11, 2018 at 18:14
  • $\begingroup$ for any kind of classification problem the first approach to model the problem should be the simplest. his question was How do I model time values? $\endgroup$ May 11, 2018 at 18:28
  • $\begingroup$ @FedericoCaccia Your answer seems to be telling how do I solve this problem and which algorithm do I choose and talks about linearity. Like FadiBakoura said I am more concerned with modelling time values. The problem here is I cannot simply encode the date and time values. I am trying to encode date as - season, day of the month, month and time as values between 1 - 48. $\endgroup$
    – amitection
    May 12, 2018 at 9:27
  • 1
    $\begingroup$ If you have your data in a csv for example, you can use pandas.read_csv(file, parse_dates = True, infer_datetime_format = True) $\endgroup$ May 12, 2018 at 14:33

When you are a hammer, every problem looks like a nail.

This is a textbook problem in time-series analysis, and has been engaged with some decent levels of success using things like auto-regressive methods (ARIMA...) since the 1970's era.

How you handle your data depends on the nature of the data. Mileage varies. There is no silver bullet.

Here are some examples where variations of it are engaged.


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.