I'm trying to develop a multi regression model to predict energy consumption during one day period. X-set dimension is (10178, 52) and consist of 52-feature and Y-set dimension is (10178, 48) as output. I have used the following code:

xtrain, xtest, ytrain, ytest=train_test_split(X, Y, test_size=0.1)

in_dim = X.shape[1]
out_dim = Y.shape[1]
model = Sequential()

model.add(Dense(48*4, input_dim=in_dim, activation="relu"))

model.add(Dense(86, activation="relu"))
model.compile(loss="mean_absolute_error", optimizer="adam")
model.fit(xtrain,ytrain, epochs=100, batch_size=12,)

after compiling my model although my model's loss is very low but when I visualize my output the result is unsatisfying as follow:

enter image description here

any idea what I'm doing wrong?!? my initial guess is that since output dimension is high(48-dimension) compared to input dimension I need a lot more Data. or maybe I'm using wrong loss function or the model is too shallow. also it is noticeable that model's output at spark point is very poor.


As you can see, your predictions are able to catch the trends. In other words, the model is able to predict the direction of movement almost every day.

The only point that it is not able to catch is those high peaks, which can be treated as outliers. It is because due to seasonality or some other cause your daily data drastically changes on some of the days. This change is not normal for models to capture because those points deviate from the general characteristics of your time series.

It is quite normal having low energy consumption for 6 consecutive days but having a large energy consumption on the 7th day if you would consider that 6 days were sunny and suddenly the weather gets cold. This is just one single case where there might be lots of those.

To capture these anomalies you should have a variable to explain to them (e.g. Image that those anomalies are only due to weather conditions, then including weather variable would help you. However, it is too hard to find all those variables that explain all anomalies).

To solve the issue, you can decrease the frequency of your data. That is, instead of modeling daily data you can model weekly average or weekly end (means last day of every week), or even monthly average or monthly end.

If these outliers are consistent every week, averaging them will help you. In any case, I think decreasing the frequency of your data will help you.

To summarize, there is not a wrong thing with your model, it is just outliers make it unhandy in some predictions.

  • $\begingroup$ thanks for your explanation so, you mean I'm doing everything right and that's only the matter of outlier handling?! I think clipping high peaks before training or separating working days and weekends would also help. BTW do you think it makes sense to use a model for multi-regression with such a high dimension?(input:52-dimension ,output:48-dimension) $\endgroup$ – MAHDl EMAD Nov 13 '20 at 14:17
  • $\begingroup$ Clipping them would not be a good approach, because they are natural outliers. In any case, if you don't handle those outliers properly, your predictions will not be perfect because you will underpredict those natural outliers in the future. I think you should consider at least weekly predicting. Answer to your question: Why not? If it is a well-built model, then it is ok. $\endgroup$ – Shahriyar Mammadli Nov 13 '20 at 16:22

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.