for the python wrapper, if you try to fit a model on a dataframe that has only 0's at y, it results on a RuntimeError: Initialization failed.
@eloiup
If your data frame has only zero values, why would you try to learn something out of that data? Your predictions will only be zeros ...
If you still want to understand where the error might come from. Here is the answer:
When you fit your prophet instance to the data, there is a first call to the setup_dataframe method whose parameter initialize_scales is set to True. See here.
Looking at the method itself you can see that when the parameter initialize_scales is at True, the values are scaled. Since the maximum value in your data frame is 0, it throws an Error because of the division by zero.
Thanks, this was also just noted in #144 . There certainly needs to be a more graceful way of handling all y's equal to 0.
This issue popped up when I was iterating over thousands of groups for prediction. Occasionally, a group would contain all zeros. Hard to catch unless you pre-process the data upfront. Perhaps an easy fix is if the y's are all 0, then just skip the scaling and simply predict all 0? I can attempt to address this if you'd like.
Agreed, and a PR for this would be awesome.
I think what we'd want to do is set the scaling to 1. or something other than zero, and then skip optimizing and just set all of the model parameters to 0. This is in m.params, which is a dictionary with keys 'k', 'sigma_obs', 'm', 'beta', 'delta', 'gamma']. These are all arrays with 1 row, and the number of columns you can pull from the stan code.
This can be done after the line self.set_changepoints(), and then just return, skipping the rest of the fit code.
This fixed has been pushed with the new version.