Inverted prediction with regressor?
See original GitHub issueHi all,
First of all, thanks for your work on this awesome repository!
I’m having some issues with an ‘exploding’ forecast that seems to be kind of inverted. I’m creating a Prophet model for ‘Object A’ that doesn’t have a lot of data. Therefore, there’s no seasonality found in the data and thus only a trend available. To compensate for this, I’m extracting the seasonality component from a model that was trained on ‘Group A’ to which ‘Object A’ belongs (and which has more data available). I’m then adding the seasonality output from the ‘Group A’ model as a regressor to the model of ‘Object A’.
So to summarise: The seasonality of ‘Group A’ (to which ‘Object A’ belongs) is added as a regressor to ‘Object A’. You can find a small schematic overview of this below.
You can see the prediction of ‘Object A’, together with the components, in the screenshot below.
(Left top graph is the trend of ‘Object A’; left bottom graph is the regressor and thus the seasonality of ‘Group A’; right graph is the prediction of ‘Object A’)
The issue here is that the prediction is kind of ‘exploding’ in the wrong direction. You can see that the extra regressor is going up around 2021-03/2021-04, but the actual prediction is going down. Around 2021-06, the regressor is going down again, while the prediction is actually going up.
I don’t really understand how this is happening as this way of working (extracting seasonality data from a model and using it in another model) is working fine for all my other models. I suppose it has something to do with the negative trend, but I still don’t feel like it is expected behaviour?
The regressor is added to the model using the following code:
model.add_regressor('Regressor Name', mode='multiplicative')
The model itself is simply created with the following code:
model = Prophet()
Extra remarks
- The data itself is of weekly format.
- The data can not go into negative (should always be positive). I’m currently using the ‘clipping’ approach from #1668 where I simply clip predicted negative values to 0.
- I’m using
Prophet 0.7.1
together withPython 3.7
- The seasonality which I’m using of ‘Group A’ is the following:
Thank you in advance for any input and/or solution!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (4 by maintainers)
Top GitHub Comments
Thanks again for your answer! I indeed tried something like this already in the past, but the program would just be stuck on some kind if infinite loop, so that probably has to do with the
m.y_scale
you’re talking of. I’ll try to hackm
into that function, thanks a lot for this!On the other hand, I was pleasantly surprised with the results that I got when using the
growth='flat'
solution from @hansukyang !For Object A:
For Object B:
The results make sense, as I wanted more ‘weight’ on the regressor. It also actually didn’t make any sense to get a real trend based on only a few datapoints, so this is kind of solved here. I will still experiment by adding eg. the trend of ‘Group A’ and ‘Group B’ respectively (instead of only adding their seasonalities) to still have some kind of ‘real trend’ in there!
Thank you again to @bletham and @hansukyang ! You’ve been both really helpful! I might still update this issue in the future with additional findings I encounter.
Ah, yes, I should have noticed that sooner. The
is resetting the trend to have 0 slope (k_t) and 0 offset (m_t) at indx_neg so that the trend is flat at 0. To have the trend be flat at 1/y_scale, What we really want is to have 0 slope and offset 1/y_scale. So
should do the job. I would worry a little bit about relying on < for the float comparison with 1/y_scale, so I’d probably add a little tolerance in there, like add an extra 1e-6 or something to m_t.