6
$\begingroup$

I have some daily sales from 2018-01-01 to 2021-10-21 and I'm trying to predict the sales a year into the future. I opted for facebook prophet. My raw data looks like this:

enter image description here

According to a DF-test, the series is stationary. However according to the documents, prophet does not need stationarity to be efficient. The forecast and fit looks like this:

enter image description here

Clearly prophet is not good at capturing the spikes of the data. Looking at the mean absolute percentage errors over a horizon it just looks horrible:

enter image description here

The mean of these MAPE's is a whopping 53%, and I'm hoping one something at around 5%. Does anyone have a clue on what I can do in order to improve on this model? Obviously if I take the logarithm of the sales the relative error will decrease, but if I inverse transform it back to original it's still quite off in predictions.

EDIT:

Here is the updated forecast with holidays inserted. Seems as if the spikes are better captured but it's several hundreds of thousands of dollars in difference between predicted and actual. I get an RMSE of 1 281 915.

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ A better model might predict another Black Friday spike but looking at your data, this spike was more than twice as big in 2020 compared to the other years. There is no way to predict that from the data or to predict whether the spike in 2022 will be more like 2020 or more like the other years. Maybe some out of the model information can predict that but the raw sales data cannot. This difference on its own already gives you a high MAPE. $\endgroup$
    – quarague
    Nov 4, 2021 at 9:12

1 Answer 1

15
$\begingroup$

You have suspiciously regular massive spikes sometime about halfway through the third quarter of every year. You don't tell us where your data come from, but if they are US, this is presumably a Black Friday effect. Have you told your model about this very specific predictor?

In general, How to know that your machine learning problem is hopeless? may be helpful. You will need to understand your data and include any relevant predictors you have. Hoping for 5% MAPE may simply be unrealistic.

Also, note that your model will try to separate noise from signal and predict only the signal, with the result that your predictions will vary less than observations. Here is a recent thread on this.

Finally, you may want to take a look at What are the shortcomings of the Mean Absolute Percentage Error (MAPE)? I don't know which objective function Prophet optimizes for, but I assume it is not MAPE. Thus, if your bonus depends on having a low MAPE, you may get closer by post-processing the Prophet forecasts. (I have never seen a business problem that would benefit more from MAPE-optimal forecasts rather than, e.g., MSE- or quantile loss-optimal forecasts. And as you see at that thread, optimal forecasts can depend quite heavily on the evaluation measure.)

$\endgroup$
6
  • 2
    $\begingroup$ That is exactly correct, those are Black Friday spikes! No I have not told my model this because I was unsure how to. Is it in the same way as they do in the prophet-docs where they specify superbowl as special event? $\endgroup$
    – Parseval
    Nov 3, 2021 at 10:54
  • 1
    $\begingroup$ I have no experience with Prophet, but I would assume that that would exactly the way to go about this. $\endgroup$ Nov 3, 2021 at 10:56
  • 3
    $\begingroup$ +1. Just to close the loop on this: @Parseval That documentation is 100% what you would follow for adding extra variables and it will fit them like a normal regression along with the other components essentially like a GAM. Prophet is bayesian so the objective is the MAP. In terms of the raw accuracy, Prophet has a lot of pros but that isn't one of them. It is typically outperformed pretty handily by other methods like smoothers so you could give them a shot. $\endgroup$
    – Tylerr
    Nov 3, 2021 at 12:58
  • $\begingroup$ @Parseval You can add BF as a custom holiday in Prophet. $\endgroup$
    – dimitriy
    Nov 3, 2021 at 15:02
  • $\begingroup$ @Tylerr - I've updated my forecast with a figure capturing black weeks and christmas holidays. It seems to capture the spikes a little better but the mape is still 53%. I also tried an LSTM but it was very bad, I don't understand how some authors on TowardsDataScience can get nearly spot on predictions. Do you have any good source where I can see how smoothers are implemented? Never heard of these. $\endgroup$
    – Parseval
    Nov 4, 2021 at 9:58

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.