I am experimenting with 3 years time series electrical demand data (kW) for a building and attempting to create regression supervised ML models from sci kit learn regressor algorithms but I have very poor performance (very high mean squared error). I have a GitHub Gist of the entire IPython notebook here.

There isn't a lot of wisdom here (and I don't have anyone to consult with) for what I am doing other than I know there is well developed analytic software (demand forecasting) that the power consulting industry uses and I am just attempting to recreate from scratch on own experimentation methods in Python.

The data that I am processing look like this below all recorded in 15 minute intervals.

            Date_Time    kW
0 2011-03-01 00:15:00 171.36
1 2011-03-01 00:30:00 181.44
2 2011-03-01 00:45:00 175.68
3 2011-03-01 01:00:00 180.00

The distribution of the kW data looks like this pic below which doesn't appear to have a bell shaped curve: (Could this be a poor performance reason?)

enter image description here

EDIT rolling average plot

enter image description here

Also in my experimentation I am adding in additional Python Pandas dataframes to represent the integer value of the time stamp 'day of the week', hour, minute, and month; where logically I am know electrical demand fluctuates greatly depending on these variables. These are some scatter plots below of the data compared to kW. (which maybe screwing everything up) For example the first scatter below is the hour of the day which is typical for buildings that the electrical demand increases during a typical work day. The outliers are most likely extreme weather conditions causing high demand where I do not have any weather data incorporated here...

enter image description here enter image description here enter image description here enter image description here

In python if I do a df.describe:

enter image description here

Ultimately I am hoping someone can give me some tips on why the model is horrible but maybe its just due to not enough data and/or strategy... Another person I have been questioning uses a clustering unsupervised learning approach but that doesn't make any sense to me...

Machine learning mastery also has a mini course and a large book I could purchase on time series forecasting. Is this more of a statistics approach? Does it require more 'normal' bell shaped distribution of the data?

Any tips to try or avenues to march down is greatly appreciated :)

EDIT GitHub gist was updated for a rolling average of the data as well as distribution column plot of kW data

  • $\begingroup$ Before getting into details, I assume you have fluctuations, on daily basis, then training on the actual data points is quite difficult as it is very noisy! Have you tried to do a rolling mean of "kW" or any other averaging method to reduce those noise a bit? I do not know instead of 15-min data point, maybe average on every 2-hr, 4-hr or so...you gotta try various windows, and see how it improves. $\endgroup$ Commented Feb 13, 2019 at 21:54
  • $\begingroup$ I’ll try resembling the data to average it per hour.. thanks! Is noise fluctuations in the data that don’t affect the “big picture”? $\endgroup$
    – bbartling
    Commented Feb 13, 2019 at 22:53
  • $\begingroup$ Yes it wont. Your problem is a a time-series in nature. Basically you have soem of sort of seasonality, trend etc, you have to make your series non-stationary, rolling averaging is one way or up-sampling or.., just google you will find lots of materials. It is only when you have a stable changes in your target, simple models like those you used would give a reasonable result. Good luck. $\endgroup$ Commented Feb 14, 2019 at 6:48
  • $\begingroup$ I may need to take that "Yes it wont." back, it depends!! Surely some information will be lost, but it helps to generalize. $\endgroup$ Commented Feb 14, 2019 at 9:09
  • $\begingroup$ @MajidMortazavi thanks for the tips, I updated everything including the Gist for a rolling average... And it didn't improve ML mean squared error much... The distribution of the data plot is a bit less "smooth" looking... The curve almost looks (I think) exponential. Does that have an affect on ML algorithms?? $\endgroup$
    – bbartling
    Commented Feb 14, 2019 at 15:10

2 Answers 2


I understand you must have researched before opting the regression model.But I want to highlight one thing here that since that data is time series one,we have to be more careful here and use the models which takes the account of moving average and other time series factors. Also,cross validation is different for timeseries analysis. Having said that please use other models like ARIMA or SARIMA for your time series if your objective is to have higher accuracy.


It seems to me that your premise for doing this is potentially flawed. It sounds like you're trying to replicate some information that power companies can generate but they are working with more broad datasets than you have presented here. In turn, this can be a reason why your accuracy scores as so poor.

For example, consider that weather has an effect on power usage. So unless you're wrangling in weather data at some point, you will (1) most likely never achieve the most accurate model possible (might just be "adequate") and (2) most likely never approach similar results to what your power company can generate.

So, I would take a step back and consider your current data points; it's highly likely that you just don't have the right factors there in place to create the accurate model you seek.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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