Why does the addition of quarterly seasonality increase the fit time of my model so much?
I have incorporated quarterly seasonality into my Prophet model by adding this
self.model.add_seasonality(
name='quarterly', period=(365 / 4),
fourier_order=self.quarterly_fourier_order,
prior_scale=self.quarterly_prior_scale,
mode=self.quarterly_mode
)
and the fit time goes from seconds to minutes. I have the quarterly_fourier_order set to 7.0 to 10.0 at the lower end it takes 1 minutes from 1.7 seconds and on the upper end it takes nearly 2 mintues.
Could anyone provide insight into why?
Just adding some more context - I am allowing a hyper-parameter search and allowing the mode to be either additive or multiplicative and when the mode is set to multiplicative is when the increase in computational time occurs.
Can you see in the terminal the output of the Stan optimizer? I'm wondering if it is doing many more iterations with this seasonality than it is without. My guess would be that this seasonality isn't very well identified which can make the likelihood surface flat near the optimum, and can cause the optimizer to take more steps before it converges and terminates.
The default iterations number is too large , even 300 iters would cost 100s in when there is 2000 points . @bletham Does it really exist a situation need such large iterations to reach converge ?
When model parameters are not well identified it's possible for the gradient to get really small but not small enough to trigger the termination condition. In this situation it can take a lot of iterations. I don't have a whole lot of suggestions here. You can try using the Newton optimizer (m.fit(df, algorithm='Newton')) to see if it does a better job of terminating, though it's time-per-iteration is longer than default L-BFGS so it's often slower for large datasets.
fbprophet usually cost 1s when trainset is 1000~3000 points. However it would never converge on some dataset , so I have to modify the code reduce iteration to 300 . Even 300 cost 100s , you can imagine how terrible perfomance on default iteration 100000 .... that is why I wonder is there a reality example need such large iters . I think it would be better to calculate iteration number by input dataset size .
The default is a high value (10,000) because it's meant to never be reached and the optimizer will generally terminate before that due to one of the other termination criteria (function value no longer improving, gradient close to 0, etc.). In these cases you've run into where that isn't the case and you are not seeing practically relevant improvements in the later iterations, then you can definitely override that by passing in e.g. m.fit(df, iter=1000).
@bletham I was able to fix this issue during model fit by your m.fit(df, iter=1000). But I am again facing this while doing cross validation. Is there a way to resolve that ?