additional_topics.md (prophet-1.1) | : | additional_topics.md (prophet-1.1.1) | ||
---|---|---|---|---|
skipping to change at line 91 | skipping to change at line 91 | |||
A Dictionary containing retrieved parameters of m. | A Dictionary containing retrieved parameters of m. | |||
""" | """ | |||
res = {} | res = {} | |||
for pname in ['k', 'm', 'sigma_obs']: | for pname in ['k', 'm', 'sigma_obs']: | |||
res[pname] = m.params[pname][0][0] | res[pname] = m.params[pname][0][0] | |||
for pname in ['delta', 'beta']: | for pname in ['delta', 'beta']: | |||
res[pname] = m.params[pname][0] | res[pname] = m.params[pname][0] | |||
return res | return res | |||
df = pd.read_csv('../examples/example_wp_log_peyton_manning.csv') | df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/exampl es/example_wp_log_peyton_manning.csv') | |||
df1 = df.loc[df['ds'] < '2016-01-19', :] # All data except the last day | 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 | 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) # Adding the last day, fitting from scratch | |||
%timeit m2 = Prophet().fit(df, init=stan_init(m1)) # Adding the last day, warm- starting from m1 | %timeit m2 = Prophet().fit(df, init=stan_init(m1)) # Adding the last day, warm- starting from m1 | |||
``` | ``` | |||
1.33 s ± 55.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) | 1.33 s ± 55.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) | |||
185 ms ± 4.46 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) | 185 ms ± 4.46 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) | |||
As can be seen, the parameters from the previous model are passed in to the fitt ing for the next with the kwarg `init`. In this case, model fitting was about 5x faster when using warm starting. The speedup will generally depend on how much the optimal model parameters have changed with the addition of the new data. | As can be seen, the parameters from the previous model are passed in to the fitt ing for the next with the kwarg `init`. In this case, model fitting was about 5x faster when using warm starting. The speedup will generally depend on how much the optimal model parameters have changed with the addition of the new data. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added |