Commit graph

411 commits

Author SHA1 Message Date
Julian Carrasquillo
cc5484c4e3
adding no history error handling to cross_validation (#2140) 2022-05-23 03:12:46 +10:00
Cuong Duong
0a44095570 pin holidays >=0.13 to fix UK bug 2022-05-23 02:36:14 +10:00
Cuong Duong
385e2afb43
Small fixes to setup and readme (#2175) 2022-05-22 19:40:41 +10:00
Brian Ward
df411c9192
Remove pystan, leave backend abstraction for now (#2148) 2022-05-05 17:37:17 +10:00
Brian Ward
9968f8be41
Simplify setup.py, make CmdStan the default backend (#2088) 2022-04-05 00:06:59 +10:00
Aliaksandr Barouski
efca9301ce
Fixing potential security issue (#2108)
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>
2022-01-31 14:18:56 -05:00
Cuong Duong
04ffdc997d
Add Windows wheel (#2089) 2021-12-25 23:20:24 +11:00
Cuong Duong
9cdad80c36 hotfix setup.py 2021-10-04 10:16:55 +11:00
Anurag Kumar
675ece7d6a
Update setup.py (#2027) 2021-10-03 18:42:38 +11:00
Cuong Duong
4fb577e5d4
(Stage 1) Python Wheels for PyPi (#2010) 2021-10-03 12:03:03 +11:00
Cuong Duong
fabf67e73d
Set lower bound for holidays to 0.11.3.1 (#2038) 2021-10-03 05:29:04 +11:00
Marco Edward Gorelli
17dbb86ab0
Speed up make_holiday_features by up to 35% (#1962) 2021-08-28 12:19:40 +10:00
Cuong Duong
be87004df9 Merge remote-tracking branch 'upstream/master' into minor-fixing 2021-08-28 02:04:44 +10:00
slowy07
05aa1fdd37 fix: typo grammar 2021-08-03 08:37:45 +07:00
Drobin Max
d8d819a34f
Update forecaster.py
added 'flat' growth option in docstring
2021-05-24 17:32:14 +03:00
Greg Rafferty
4b859bca01
added argument for point color to cv plot (#1895) 2021-05-10 16:04:34 -07:00
Ben Sully
0616bfb5da
Add model_to_dict and model_from_dict functions (#1871)
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).
2021-04-20 18:10:06 -07:00
Ben Letham
83c4ef3e2b Merge branch 'patch-1' of https://github.com/loulo1/prophet into loulo1-patch-1 2021-04-20 17:49:17 -07:00
Ben Letham
847ecee033 Merge 2021-04-20 17:43:10 -07:00
loulo1
3a0061e8e1
change init into inits for CmdStanPyBackend 2021-04-14 15:39:02 +02:00
Vladimir Shargin
899b4fac13
Add include_legend flag to m.plot() (#1858) 2021-04-03 18:01:41 -04:00
Sean Taylor
94e5d2e80a Bump version numbers 2021-03-26 15:36:07 -07:00
Sean Taylor
82f3399409 Pin to last 2.* Pystan release. 2021-03-25 22:15:10 -07:00
Ben Letham
6d81543eb2
Pakage rename (#1844)
* Rename package from fbprophet to prophet, and add shim

* Untrack files that should have been ignored

* Update github actions build commands
2021-03-21 14:13:50 -07:00
Cuong Duong
16472a5700
Upgrade CmdStanPy interface (#1849)
* 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>
2021-03-20 10:59:58 -07:00
Cuong Duong
8ffa0e02a6
use builtin int and float (#1850) 2021-03-20 10:50:14 -07:00
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
Ben Letham
8882c6a3e3 Use pathlib to load model file (#1835) 2021-03-05 09:55:35 -08:00
Ben Letham
49a89d2a4e Bump version in unit test 2021-03-04 20:12:34 -08:00
Ben Letham
612934695b Version bump 2021-03-04 17:16:23 -08:00
Ben Letham
eb6b8f60ec Enable cross validation on a deserialized model (#1709) 2021-03-03 18:40:27 -08:00
Ben Letham
bbc44bf67c Add test for backwards compatibility with v0.7.1 serialized models 2021-03-03 18:14:16 -08:00
Ben Letham
a1803a8801 Minor rearrange 2021-03-03 18:09:59 -08:00
Ben Letham
74b21f7cd9 Error for unrecognized options in StanBackend.set_options 2021-03-03 18:04:15 -08:00
Ben Letham
f123a1a7cc Fix holidays NA handling 2021-03-03 16:06:25 -08:00
Ben Letham
2e9f831474 Check for NAs in holiday dataframe 2021-03-03 15:43:49 -08:00
Ben Letham
29f14172f0 Handle numpy fit_kwargs when serializing (#1701) 2021-03-03 15:23:12 -08:00
Ben Letham
9e4e87af9b Make sure y_scale is not numpy float (#1824) 2021-03-03 14:52:08 -08:00
Nodar Okroshiashvili
ad2de1e69d
Add Georgian holidays (#1827)
* Update gitignore

* Add Georgian holidays
2021-03-01 17:25:03 -08:00
Luke Scales
9bc7fb77b5
Added optional colour to plot_cross_validation_metric (#1758)
* 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>
2021-01-07 10:50:18 -08:00
Devdutt Shenoi
20f590b726
[python] code quality improvements (#1745)
* 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
2020-12-08 15:35:54 -08:00
Aziz Alto
ee592451f2
Fix "UserWarning" in model.plot_components (#1732)
See the issue https://github.com/facebook/prophet/issues/1721
2020-11-10 11:21:23 -08:00
Sharon Woo
4f34de0363
'Added checks to cutoffs and error messages if checks fail using ValueError. Fixed earlier bug' (#1718)
* Update error message: Dataframe has no rows #1650, added err msgs

* Added error messages and checks for cutoffs"
2020-11-06 21:46:01 -08:00
Pawel Kranzberg
97bb057de4
Update performance_metrics() in diagnostics.py (#1710)
* 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
2020-11-06 21:29:32 -08:00
Greg Rafferty
0a33f381ba
X axis labels in plot_seasonality (#1707)
* changed x-axis format in plot_seasonality

* changed x-axis format in plot_seasonality
2020-11-06 21:20:59 -08:00
fbonaita
3a17402585
Tqdm flag (#1706)
* add disable_tqdm flag to diagnostics.py

* add comment to cross_validation()

* Replace boolean comparison operator

Co-authored-by: Marius Theiss <justusbersten@gmail.com>

* Fix indentation

* Restore original indentation

Co-authored-by: Filippo Bonaita <filippo.bonaita@corp.badoo.com>
Co-authored-by: Marius Theiss <justusbersten@gmail.com>
2020-11-06 21:02:54 -08:00
quant9
e41ed25646
add option to disable Newton fallback via set_options method (#1702) 2020-10-08 11:13:21 -07:00
Ben Letham
3a436ec603 Update holidays version requirement, for TR 2020-09-03 17:09:24 -07:00
Ben Letham
5faacc9fd5 Update serialize test with version change 2020-09-03 16:51:00 -07:00
Ben Letham
cb966a5244 Fix issue with holidays in some years 2020-09-03 16:47:22 -07:00
Sean Taylor
838c72fb85 Split test into fast and slow part 2020-09-02 17:38:20 -07:00
Ben Letham
96848bcc92 Fix test for python38 2020-09-02 16:34:18 -07:00
Ben Letham
2061f251f8 Clean up script for R holidays, and regenerate 2020-08-27 18:36:18 -07:00
Greg Rafferty
3d0bb6e081
fix for comma-separated holidays (#1638)
* use holidays.get_list() to return list of holidays

* make_holidays_df now accepts states
2020-08-27 17:49:19 -07:00
Ben Letham
181933b948 Change dataset for flat growth test 2020-08-24 09:17:29 -07:00
Ben Letham
ffedaa4eed Add new test file to manifest 2020-08-19 19:50:33 -07:00
Ben Letham
fb82a6a43d Minor docstring updates 2020-08-18 13:04:39 -07:00
Ben Letham
0d0f508cf1 Add test for deserialize backwards compatibility 2020-08-18 12:34:47 -07:00
Ben Letham
9084506968 Bump pandas requirement for deserialize 2020-08-17 18:38:11 -07:00
Ben Letham
a88f6458ad Fix test issues 2020-08-17 18:36:29 -07:00
Ben Letham
ccde3a498f version bump 2020-08-17 17:43:55 -07:00
Ben Letham
9fb8f103d6 Minor simplification to weekly plotting logic 2020-08-17 17:40:01 -07:00
Ben Letham
2049217471 Use y_scale in coefficient utility 2020-08-17 17:25:55 -07:00
Ben Letham
a519043f1b Fix bug in changepoint handling in prophet_copy (#1529) 2020-08-17 16:24:34 -07:00
Ben Letham
fb6552137c Deduplicate history dates for make_future_dataframe 2020-08-17 14:51:06 -07:00
Ben Letham
6ec0a90a60 Use holidays package for Turkey 2020-08-17 14:24:47 -07:00
Ben Letham
75ec9dffb1 Fix holidays for pandas 1.1.0 2020-08-14 11:03:04 -07:00
Dani
5accde4fb5
resolve python requirements : pandas<1.1.0 (#1623) 2020-08-12 14:37:15 -07:00
anqus
ad53b428c3
Plot continuous weekly seasonality with sub daily data (#1615)
* Check frequency of data

* If sub-daily, use plot_seasonality()

* Format xticks as weekdays for plot_seasonality()

* Display 8 xticks for weekly component
2020-08-12 14:30:06 -07:00
Cuong Duong
40b170b95a
Add helper function to summarise coefficients of extra regressors (#1572)
* add regressor summary fn for python

* styling, docstring

* update docstring

* fix definition for multiplicative regressor, add tests

* simpler shape test
2020-08-12 12:12:24 -07:00
Dani
1053a6e9ce
Update PyPi package metadata and resolve Travis CI failing build (#1602)
* Update PyPi package metadata setup.py 'long_description'

* Add V8 package to Travis CI config & caching pip
2020-07-29 17:02:37 -07:00
Robin Teuwens
87844821d3
Making sure 'holiday' is a Dataframe when using plot_components_ploty() (#1526)
* 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>
2020-06-10 17:33:12 -07:00
Ryan Nazareth
30bcfed918
Include mdape in performance metric docstring (#1512)
* 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>
2020-06-05 17:51:25 -07:00
Ryan Nazareth
31841c90c9
import tqdm.auto instead (#1509) 2020-06-05 17:46:41 -07:00
Chanran Kim
5669f13abf
Drop Korea class from hdays.py (#1438)
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
``
2020-06-05 16:54:58 -07:00
Ryan Nazareth
ac59b44ca3
add implementation for constant trend in Python (#1466)
* 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
2020-05-14 21:40:40 -07:00
Ryan Nazareth
cb4f1dcc59
Remove Python 2 from setup.py (#1485)
* remove python 2 from setup.py and add python_requires

* add note in README
2020-05-14 12:16:34 -07:00
above-c-level
9168dcf11d
Removed redundant line in Prophet docstring (#1474) 2020-05-06 13:00:03 -07:00
Chris Benson
98f2a7be18
Fix Issue with Pickling Models in Python3.6 because of Logger Attribute (#1452)
* Fix issue with pickeling models due to logger

* Fixes Model Pickle Error in Python3.6 as described in #1361
2020-04-28 12:30:31 -07:00
Tom Augspurger
5fe3be86c5
Parallel Cross Validation (#1434)
* API: Refactor to parallel / cf

* Added Dask-based parallelism

* fix test

* cover bad parallel

* avoid multiprocess issue under setuptools tests

* Update notebook docs

* fix docstring

* install note

* arbitrary object

* fixups

* fixups

* fixups

* remove unused import
2020-04-28 12:25:41 -07:00
Ben Letham
6cd14438c6 Update version in serialize test 2020-04-04 08:43:28 -07:00
Ben Letham
231200ffaa mark dev version 2020-04-04 08:28:42 -07:00
Ben Letham
c943d966b4
Add functions for serializing to/from JSON (#1414)
* 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
2020-04-04 08:23:27 -07:00
Marco Fusi
3c69ce3312
modified cross_validation to allow custom cutoffs (#1402)
* 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>
2020-03-26 16:36:02 -07:00
Mitzi Morris
d22922d08c
sampling iters arg name, logic changes (#1389)
* 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>
2020-03-24 14:33:52 -07:00
sheikheddy
e9771c862d
Holidays in United Arab Emirates (#1390)
Added official holidays of the UAE. Our dates for Eid are slightly longer than other countries. I tried to keep the style consistent with what's already there.  We need to add this and Belarus to the docs here: https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#built-in-country-holidays
2020-03-23 16:25:12 -07:00
Ben Letham
d9bea61969 Remvoe no longer necessary test 2020-03-09 15:20:25 -07:00
Ben Letham
44ceaa8d8b Don't use tqdm with multiprocessing starmap 2020-03-09 12:48:14 -07:00
Ryan Nazareth
39c619dbf7
Running Cross-Validation with Multiprocessing Option (#1356)
* 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
2020-03-09 12:25:01 -07:00
Dmitry
fd61fcbeeb
Holidays in Belarus + codestyle (#1380)
* Holidays in Belarus + codestyle

* Correction + changing hardcode with variable
2020-03-06 18:40:58 -08:00
Ryan Nazareth
0ca50cfb7f
Extract stanfit from model object in Py following cmdstanpy refactoring (#1353)
* add self.stan_fit in fit methods

* small changes to fix tests

* make changes to remove self.params from backend classes
2020-03-06 18:11:04 -08:00
Ben Letham
708ae20c04 lower tqdm required version 2020-03-04 16:03:22 -08:00
Ben Letham
d8dd2f53b7
Add progress bar to cross_validation (#1338)
* 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
2020-03-04 16:01:02 -08:00
Ram Rachum
952b544928
Fix exception causes in 2 modules (#1370)
Co-authored-by: Ben Letham <bletham@gmail.com>
2020-03-03 17:34:06 -08:00
JayCarraway
560077c8a7
Add possibility of selecting province of country for creation of holiday (#1340)
dataframe
2020-03-03 16:24:48 -08:00
Sean Taylor
101dd50e31 Delay some imports to allow installation w/o deps 2020-02-17 17:20:20 -08:00
Ryan Nazareth
59f34ebc5f
suppress plotly error logging (#1332)
* raise logging level to critical for plot module

* remove setlevel for plot logger
2020-02-17 15:00:14 -08:00
Christoph Deil
8c48f5b042
Remove logging.root basicConfig on fbprophet import (#1336) 2020-02-17 14:11:23 -08:00
Ben Letham
57990e6f50 Change backend logging from info to debug 2020-02-11 03:38:18 -08:00
Ben Letham
9413c1141e version bump 2020-02-09 19:16:05 -08:00