Tools/languages/techniques I am using
- python
- scikit-learn
- different regression models (only linear regression is shown here for simplicity)
I am working on a regression problem. The data I have is time-series hourly consumption data and I am trying to make a step-ahead prediction.
I first prepared the data and made sure no data from the future is spilled into the training data. So for consumption at a certain hour (h0), the record will look as follows
feature1 | feature2 | target |
---|---|---|
h-2 | h-1 | h0 |
Where h-1 and h-2 are the previous two hours.
Note
I am adding two hours here for simplicity. However, in reality, I am using different lag values and moving averages as features.
I trained the model and then applied the predict function to test data.
After that, I plotted the actual vs prediction (y_test vs y_predict), but it seems that there is some shift where the prediction is shifted by one hour in the future as you can see below
I tried to shift the prediction back by one hour the performance difference was huge
R2 increased from 0.64 to 0.89 (39% enhancement)
RMSE dropped from 1003 to 536.8 (46.5% enhancement)
My Question
- What could I be doing wrong?
- Am I doing something wrong or could this shift be an indication of something else?