An attacker could access random URL from the executing server if model is crafted. It happens
because pd.read_json checks if the parameter is string contains URL and loads it in the case. The
fix enforcing using parameter as a JSON.
Co-authored-by: Alex Barouski <barouski@fb.com>
This commit adds the model_to_dict and model_from_dict functions, using
all of the logic that previously lived in model_to_json and
model_from_json, and converting those functions to simply reuse the new
ones.
This is useful because sometimes the user may want to serialize the dict
in some other way (e.g. another JSON serialization library such as ujson
or orjson, or something entirely different).
* cmdstan variable extraction update
* add backwards compatibility
* Fix bug
* Upgrade stan version in requirements and in CI testing
Co-authored-by: Ben Letham <bletham@gmail.com>
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
* Added optional colour to plot_cross_validation_metric to facilitate the comparison of different model's performance on the one plot
* use color
Change from colour to color for consistency.
Co-authored-by: Ben Letham <bletham@gmail.com>
* 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
* Update performance_metrics() in diagnostics.py
Include smape as a valid metric.
Add support for monthly horizons.
* Update performance_metrics() docstring
* Update performance_metrics() docstring
* Include smape in test_diagnostics.py
* sMAPE code formatting improvement
* Check frequency of data
* If sub-daily, use plot_seasonality()
* Format xticks as weekdays for plot_seasonality()
* Display 8 xticks for weekly component
* Issue #1525: Using m.construct_holiday_dataframe() to make sure 'holidays' is a DataFrame.
* #1525 | issuecomment-639399524 | enhancement: have plotly graph the holiday component consistent with matplotlib.
Co-authored-by: Robin Teuwens <teuwens@electris.lu>
* update docstring with mdape in list for python perf metric func
* re-run python notebook cell to generate mdape in results table
* remove comment
Co-authored-by: Ben Letham <bletham@gmail.com>
To solve this [issue](https://github.com/facebook/prophet/issues/1437) by @chongdae
Korean lunar calendar which is different from Chinese lunar calendar is added python-holidays package recently.
This commit is about dropping the Korean and KR class in hdays.py file and hdays_part1(holidays) will work for Korean holidays.
```
import fbprophet.hdays as hdays_part2
import holidays as hdays_part1
``
* add implementation for constant trend
* force k and delta params to be 0s
* add tests and fix n_changepoints, changepoints_t to 0
* Add test for cv with constant trend
* Add docs and test for checking invalid input
* make changes to stan
* add transformed params block in stan and output flat trend vector
* correct syntax
* transformed params syntax
* Fix test and port changes to win stan file
* add test for flat trend function
* Add separate function for flat trend init
* fix test
* Add functions for serializing to/from JSON
* Fix list vs. series type issue, track version
* Avoid DateTimeIndex
* bugfix
* another fix
* Fix copy test
* Fix issue with pre-epoch dates
* Handle empty datetime series
* modified cross_validation to allow custom cutoffs
* moved set period, initials and identify larg. seas
* modified the diagnostics and added the test
* reverted cv default value tests and added a new custom cutoff test
* reorganized to raise the seasonality period warning message even if cutoffs are manually specified
* moved the initials vs. seasonality check
* changed assertCountEqual to assertItemsEqual in cv
* modified to test lengths instread of cutoff values
Co-authored-by: Fusi Marco <Marco.Fusi@valuelab.it>
* 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>
* Add multiprocessing Pool and create function for single cutoff forecast
* add params to single forecast function
* Add iterable for input params for pool
* Add docstring for single cutoff forecast func
* Add check for multiprocessing in test_cross_validation
* check ofr is None and is True and add better description for multiprocess in docstring
* Raise error if wrong args chosen and add test
* fix conflicts
* Change arg to True/False, model.kwargs
* docstring units and few more fixes
* change to iterator and add back tqdm to for loop
* add option in diagnosics notebook about multiprocessing option
* add extra test for checking calls to single forecast func
* tqdm
* Added progress bar to the crossvalidation
In order to improve the user experiance a progress bar is added to the crossvalidation loop.
* Update requirements.txt
* Update python/fbprophet/diagnostics.py
* updated further
* Update requirements.txt