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
* Add DeepSource config
* Simplify if statement
* Refactor use of dict() with empty literal
* Use set comprehension syntax
* Refactor chained comparison
* Rewrite instances of list literal within set() as set literals
* Add test_slow to class definition
* sampling iters arg name, logic changes
* Bump cmdstanpy version in requirements to 0.9.5
* Change Model to CmdStanModel
Co-authored-by: Ben Letham <bletham@gmail.com>
* changes
* added actual tests for fit method
* precision
* syntax
* sampling not working
* sampling seems to work
* sampling not working again
* sampling works, tests to be removed
* replaced data with rmse
* replace pystan with cmdstanpy
* cleanup
* cleanup
* test for newton
* added support for multiple backends
* minor fixes
* fixed comment
* added support for --test-slow flag
* fixed import
* reverted style change
* specify backend based on env variable
* fixes
* PR fixes
* Update and rename README to README.md and Unicode strings
Updated Readme file and converted from rst to markdown.
String contains ascii characters (converted to unicode string)
Signed-off-by: Mpho Mphego mpho112@gmail.com
* Deprecated import `from __future__ import unicode_literals` removed and ran isort module
https://mail.python.org/pipermail/python-dev/2016-December/147009.html
Included setuptool-git in the requirement.txt and updated `setup.py`
Reasons for this are highlighted here -> https://github.com/msabramo/setuptools-git#usage