prophet/python/fbprophet
loulo1 fc8fa49aac Fix the issue #1814
I did as PyStanBackend. And now when we use the method fit of Prophet, we can do like in the documentation:

https://facebook.github.io/prophet/docs/additional_topics.html#updating-fitted-models

def stan_init(m):
    """Retrieve parameters from a trained model.

    Retrieve parameters from a trained model in the format
    used to initialize a new Stan model.

    Parameters
    ----------
    m: A trained model of the Prophet class.

    Returns
    -------
    A Dictionary containing retrieved parameters of m.

    """
    res = {}
    for pname in ['k', 'm', 'sigma_obs']:
        res[pname] = m.params[pname][0][0]
    for pname in ['delta', 'beta']:
        res[pname] = m.params[pname][0]
    return res

df = pd.read_csv('../examples/example_wp_log_peyton_manning.csv')
df1 = df.loc[df['ds'] < '2016-01-19', :]  # All data except the last day
m1 = Prophet().fit(df1) # A model fit to all data except the last day

%timeit m2 = Prophet().fit(df)  # Adding the last day, fitting from scratch
%timeit m2 = Prophet().fit(df, init=stan_init(m1))  # Adding the last day, warm-starting from m1

Update models.py

Update models.py

Update models.py

Update models.py

Update models.py

Update models.py

Update models.py

Test

Test2

Test4

Test4

Test are fixed
2021-03-09 15:05:57 +01:00
..
tests Bump version in unit test 2021-03-04 20:12:34 -08:00
__init__.py Version bump 2021-03-04 17:16:23 -08:00
diagnostics.py Enable cross validation on a deserialized model (#1709) 2021-03-03 18:40:27 -08:00
forecaster.py Fix holidays NA handling 2021-03-03 16:06:25 -08:00
hdays.py Add Georgian holidays (#1827) 2021-03-01 17:25:03 -08:00
make_holidays.py Fix issue with holidays in some years 2020-09-03 16:47:22 -07:00
models.py Fix the issue #1814 2021-03-09 15:05:57 +01:00
plot.py Added optional colour to plot_cross_validation_metric (#1758) 2021-01-07 10:50:18 -08:00
serialize.py Handle numpy fit_kwargs when serializing (#1701) 2021-03-03 15:23:12 -08:00
utilities.py Use y_scale in coefficient utility 2020-08-17 17:25:55 -07:00