Refresh online docs, change package name in docs (#1852)
26
README.md
|
|
@ -1,12 +1,12 @@
|
|||
# Prophet: Automatic Forecasting Procedure
|
||||
|
||||

|
||||
[](https://pypi.python.org/pypi/fbprophet)
|
||||
[](https://anaconda.org/conda-forge/fbprophet/)
|
||||
[](https://pypi.python.org/pypi/prophet)
|
||||
[](https://anaconda.org/conda-forge/prophet/)
|
||||
|
||||
Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.
|
||||
|
||||
Prophet is [open source software](https://code.facebook.com/projects/) released by Facebook's [Core Data Science team](https://research.fb.com/category/data-science/). It is available for download on [CRAN](https://cran.r-project.org/package=prophet) and [PyPI](https://pypi.python.org/pypi/fbprophet/).
|
||||
Prophet is [open source software](https://code.facebook.com/projects/) released by Facebook's [Core Data Science team](https://research.fb.com/category/data-science/). It is available for download on [CRAN](https://cran.r-project.org/package=prophet) and [PyPI](https://pypi.python.org/pypi/prophet/).
|
||||
|
||||
## Important links
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ Prophet is [open source software](https://code.facebook.com/projects/) released
|
|||
- Source code repository: https://github.com/facebook/prophet
|
||||
- Contributing: https://facebook.github.io/prophet/docs/contributing.html
|
||||
- Prophet R package: https://cran.r-project.org/package=prophet
|
||||
- Prophet Python package: https://pypi.python.org/pypi/fbprophet/
|
||||
- Prophet Python package: https://pypi.python.org/pypi/prophet/
|
||||
- Release blogpost: https://research.fb.com/prophet-forecasting-at-scale/
|
||||
- Prophet paper: Sean J. Taylor, Benjamin Letham (2018) Forecasting at scale. The American Statistician 72(1):37-45 (https://peerj.com/preprints/3190.pdf).
|
||||
|
||||
|
|
@ -38,22 +38,22 @@ If you have custom Stan compiler settings, install from source rather than the C
|
|||
|
||||
## Installation in Python
|
||||
|
||||
Prophet is on PyPI, so you can use `pip` to install it. From v0.6 onwards, Python 2 is no longer supported.
|
||||
Prophet is on PyPI, so you can use `pip` to install it. From v0.6 onwards, Python 2 is no longer supported. As of v1.0, the package name on PyPI is "prophet"; prior to v1.0 it was "fbprophet".
|
||||
|
||||
```bash
|
||||
# Install pystan with pip before using pip to install fbprophet
|
||||
# Install pystan with pip before using pip to install prophet
|
||||
pip install pystan
|
||||
|
||||
pip install fbprophet
|
||||
pip install prophet
|
||||
```
|
||||
|
||||
The default dependency that Prophet has is `pystan`. PyStan has its own [installation instructions](http://pystan.readthedocs.io/en/latest/installation_beginner.html). Install pystan with pip before using pip to install fbprophet.
|
||||
The default dependency that Prophet has is `pystan`. PyStan has its own [installation instructions](http://pystan.readthedocs.io/en/latest/installation_beginner.html). Install pystan with pip before using pip to install prophet.
|
||||
|
||||
You can also choose a (more experimental) alternative stan backend called `cmdstanpy`. It requires the [CmdStan](https://mc-stan.org/users/interfaces/cmdstan) command line interface and you will have to specify the environment variable `STAN_BACKEND` pointing to it, for example:
|
||||
|
||||
```
|
||||
# bash
|
||||
$ CMDSTAN=/tmp/cmdstan-2.22.1 STAN_BACKEND=CMDSTANPY pip install fbprophet
|
||||
$ CMDSTAN=/tmp/cmdstan-2.22.1 STAN_BACKEND=CMDSTANPY pip install prophet
|
||||
```
|
||||
|
||||
Note that the `CMDSTAN` variable is directly related to `cmdstanpy` module and can be omitted if your CmdStan binaries are in your `$PATH`.
|
||||
|
|
@ -62,16 +62,16 @@ It is also possible to install Prophet with two backends:
|
|||
|
||||
```
|
||||
# bash
|
||||
$ CMDSTAN=/tmp/cmdstan-2.22.1 STAN_BACKEND=PYSTAN,CMDSTANPY pip install fbprophet
|
||||
$ CMDSTAN=/tmp/cmdstan-2.22.1 STAN_BACKEND=PYSTAN,CMDSTANPY pip install prophet
|
||||
```
|
||||
|
||||
After installation, you can [get started!](https://facebook.github.io/prophet/docs/quick_start.html#python-api)
|
||||
|
||||
If you upgrade the version of PyStan installed on your system, you may need to reinstall fbprophet ([see here](https://github.com/facebook/prophet/issues/324)).
|
||||
If you upgrade the version of PyStan installed on your system, you may need to reinstall prophet ([see here](https://github.com/facebook/prophet/issues/324)).
|
||||
|
||||
### Anaconda
|
||||
|
||||
Use `conda install gcc` to set up gcc. The easiest way to install Prophet is through conda-forge: `conda install -c conda-forge fbprophet`.
|
||||
Use `conda install gcc` to set up gcc. The easiest way to install Prophet is through conda-forge: `conda install -c conda-forge prophet`.
|
||||
|
||||
### Windows
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ On Windows, PyStan requires a compiler so you'll need to [follow the instruction
|
|||
|
||||
### Linux
|
||||
|
||||
Make sure compilers (gcc, g++, build-essential) and Python development tools (python-dev, python3-dev) are installed. In Red Hat systems, install the packages gcc64 and gcc64-c++. If you are using a VM, be aware that you will need at least 4GB of memory to install fbprophet, and at least 2GB of memory to use fbprophet.
|
||||
Make sure compilers (gcc, g++, build-essential) and Python development tools (python-dev, python3-dev) are installed. In Red Hat systems, install the packages gcc64 and gcc64-c++. If you are using a VM, be aware that you will need at least 4GB of memory to install prophet, and at least 2GB of memory to use prophet.
|
||||
|
||||
## Changelog
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ In Python, models should not be saved with pickle; the Stan backend attached to
|
|||
```python
|
||||
# Python
|
||||
import json
|
||||
from fbprophet.serialize import model_to_json, model_from_json
|
||||
from prophet.serialize import model_to_json, model_from_json
|
||||
|
||||
with open('serialized_model.json', 'w') as fout:
|
||||
json.dump(model_to_json(m), fout) # Save model
|
||||
|
|
@ -43,7 +43,7 @@ with open('serialized_model.json', 'w') as fout:
|
|||
with open('serialized_model.json', 'r') as fin:
|
||||
m = model_from_json(json.load(fin)) # Load model
|
||||
```
|
||||
The json file will be portable across systems, and deserialization is backwards compatible with older versions of fbprophet.
|
||||
The json file will be portable across systems, and deserialization is backwards compatible with older versions of prophet.
|
||||
|
||||
|
||||
<a id="flat-trend-and-custom-trends"> </a>
|
||||
|
|
@ -67,7 +67,7 @@ Note that if this is used on a time series that doesn't have a constant trend, a
|
|||
|
||||
|
||||
|
||||
To use a trend besides these three built-in trend functions (piecewise linear, piecewise logistic growth, and flat), you can download the source code from github, modify the trend function as desired in a local branch, and then install that local version. This PR provides a good illustration of what must be done to implement a custom trend: https://github.com/facebook/prophet/pull/1466/files.
|
||||
To use a trend besides these three built-in trend functions (piecewise linear, piecewise logistic growth, and flat), you can download the source code from github, modify the trend function as desired in a local branch, and then install that local version. This PR provides a good illustration of what must be done to implement a custom trend (https://github.com/facebook/prophet/pull/1466/files), as does this one that implements a step function trend (https://github.com/facebook/prophet/pull/1794) and this one for a new trend in R (https://github.com/facebook/prophet/pull/1778).
|
||||
|
||||
|
||||
<a id="updating-fitted-models"> </a>
|
||||
|
|
@ -111,11 +111,11 @@ 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
|
||||
```
|
||||
1.44 s ± 121 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
|
||||
860 ms ± 203 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)
|
||||
|
||||
|
||||
As can be seen, the parameters from the previous model are passed in to the fitting for the next with the kwarg `init`. In this case, model fitting was almost 2x 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 fitting 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.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ We appreciate all contributions. If you are planning to contribute back bug-fixe
|
|||
|
||||
If you plan to contribute new features or extensions to the core, please first open an issue and discuss the feature with us. Sending a pull request is fine too, but it will likely be merged more quickly if any design decisions are settled on beforehand in an issue.
|
||||
|
||||
The R and Python versions are kept feature identical, but new features can be implemented for each method in separate commits.
|
||||
We try to keep the R and Python versions feature identical, but new features can be implemented for each method in separate commits.
|
||||
|
||||
The following sections will describe how you can submit a pull request for adding enhancements, documentation changes or bug fixes to the codebase.
|
||||
|
||||
## 1. Forking the Prophet Repo
|
||||
|
||||
You will need your own fork to work on the code. Go to the [fbprophet project
|
||||
You will need your own fork to work on the code. Go to the [prophet project
|
||||
page](https://github.com/facebook/prophet) and hit the ``Fork`` button. You will
|
||||
want to clone your fork to your machine:
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ $ cd prophet
|
|||
$ git remote add upstream https://github.com/facebook/prophet.git
|
||||
```
|
||||
This creates the directory `prophet` and connects your repository to
|
||||
the upstream (main project) fbprophet repository.
|
||||
the upstream (main project) prophet repository.
|
||||
|
||||
## 2. Creating an environment with dependencies
|
||||
|
||||
|
|
@ -89,14 +89,13 @@ The next step is to build and install the development version of prophet in the
|
|||
$ python setup.py develop
|
||||
```
|
||||
|
||||
You should be able to import *fbprophet* from your locally built version:
|
||||
You should be able to import *prophet* from your locally built version:
|
||||
|
||||
```bash
|
||||
$ python # start an interpreter
|
||||
>>> import fbprophet
|
||||
>>> fbprophet.__version__
|
||||
'0.6.1.dev0' # whatever the current github version is
|
||||
'0.10.0+dev46.g015daca'
|
||||
>>> import prophet
|
||||
>>> prophet.__version__
|
||||
'1.0' # whatever the current github version is
|
||||
```
|
||||
|
||||
This will create the new environment, and not touch any of your existing environments,
|
||||
|
|
@ -132,7 +131,7 @@ $ git checkout -b new-feature
|
|||
|
||||
This changes your working directory to the new-feature branch. Keep any
|
||||
changes in this branch specific to one bug or feature so it is clear
|
||||
what the branch brings to *fbprophet*. You can have many "new-features"
|
||||
what the branch brings to *prophet*. You can have many "new-features"
|
||||
and switch in between them using the ``git checkout`` command.
|
||||
|
||||
To update this branch, you need to retrieve the changes from the master branch:
|
||||
|
|
@ -142,7 +141,7 @@ $ git fetch upstream
|
|||
$ git rebase upstream/master
|
||||
```
|
||||
|
||||
This will replay your commits on top of the latest *fbprophet* git master. If this
|
||||
This will replay your commits on top of the latest *prophet* git master. If this
|
||||
leads to merge conflicts, you must resolve these before submitting your pull
|
||||
request. If you have uncommitted changes, you will need to ``git stash`` them
|
||||
prior to updating. This will effectively store your changes and they can be
|
||||
|
|
@ -151,9 +150,7 @@ reapplied after updating.
|
|||
|
||||
## 5. Testing with Continuous Integration
|
||||
|
||||
Adding tests is one of the most common requests after code is pushed to prophet. Therefore, it is worth getting in the habit of writing tests ahead of time so this is never an issue. Once your pull request is submitted, the Travis CI (continuous integration) service automatically triggers Python and R builds for Prophet and runs the tests. A pull-request will be considered for merging when you have an all ‘green’ build. If any tests are failing, then you will get a red ‘X’, where you can click through to see the individual failed tests.
|
||||
|
||||
All contributors are strongly recommended to embrace Test Driven Development (TDD). First one must write an (initially failing) automated test case that defines a desired improvement or new function, then produce the minimum amount of code to pass that test. So, before actually writing any code, you should write your tests.
|
||||
Adding tests is one of the most common requests after code is pushed to prophet. Therefore, it is worth getting in the habit of writing tests ahead of time so this is never an issue. Once your pull request is submitted, the Github Actions CI (continuous integration) service automatically triggers Python and R builds for Prophet and runs the tests. A pull-request will be considered for merging when you have an all ‘green’ build. If any tests are failing, then you will get a red ‘X’, where you can click through to see the individual failed tests.
|
||||
|
||||
### Python
|
||||
|
||||
|
|
@ -257,7 +254,7 @@ upstream https://github.com/facebook/prophet.git (fetch)
|
|||
upstream https://github.com/facebook/prophet.git (push)
|
||||
```
|
||||
|
||||
Now your code is on GitHub, but it is not yet a part of the fbprophet project. For that to happen, a pull request needs to be submitted on GitHub.
|
||||
Now your code is on GitHub, but it is not yet a part of the prophet project. For that to happen, a pull request needs to be submitted on GitHub.
|
||||
|
||||
## 9. Review your code
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,24 @@ docid: "diagnostics"
|
|||
title: "Diagnostics"
|
||||
permalink: /docs/diagnostics.html
|
||||
subsections:
|
||||
- title: Cross validation
|
||||
id: cross-validation
|
||||
- title: Parallelizing cross validation
|
||||
id: parallelizing-cross-validation
|
||||
- title: Hyperparameter tuning
|
||||
id: hyperparameter-tuning
|
||||
---
|
||||
<a id="cross-validation"> </a>
|
||||
|
||||
### Cross validation
|
||||
|
||||
|
||||
|
||||
Prophet includes functionality for time series cross validation to measure forecast error using historical data. This is done by selecting cutoff points in the history, and for each of them fitting the model using data only up to that cutoff point. We can then compare the forecasted values to the actual values. This figure illustrates a simulated historical forecast on the Peyton Manning dataset, where the model was fit to a initial history of 5 years, and a forecast was made on a one year horizon.
|
||||
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
[The Prophet paper](https://peerj.com/preprints/3190.pdf) gives further description of simulated historical forecasts.
|
||||
|
|
@ -38,7 +46,7 @@ head(df.cv)
|
|||
```
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.diagnostics import cross_validation
|
||||
from prophet.diagnostics import cross_validation
|
||||
df_cv = cross_validation(m, initial='730 days', period='180 days', horizon = '365 days')
|
||||
```
|
||||
```python
|
||||
|
|
@ -78,45 +86,45 @@ df_cv.head()
|
|||
<tr>
|
||||
<th>0</th>
|
||||
<td>2010-02-16</td>
|
||||
<td>8.956828</td>
|
||||
<td>8.460272</td>
|
||||
<td>9.476844</td>
|
||||
<td>8.959678</td>
|
||||
<td>8.470035</td>
|
||||
<td>9.451618</td>
|
||||
<td>8.242493</td>
|
||||
<td>2010-02-15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>2010-02-17</td>
|
||||
<td>8.723230</td>
|
||||
<td>8.208639</td>
|
||||
<td>9.222179</td>
|
||||
<td>8.726195</td>
|
||||
<td>8.236734</td>
|
||||
<td>9.219616</td>
|
||||
<td>8.008033</td>
|
||||
<td>2010-02-15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>2010-02-18</td>
|
||||
<td>8.607021</td>
|
||||
<td>8.106506</td>
|
||||
<td>9.104792</td>
|
||||
<td>8.610011</td>
|
||||
<td>8.104834</td>
|
||||
<td>9.125484</td>
|
||||
<td>8.045268</td>
|
||||
<td>2010-02-15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>2010-02-19</td>
|
||||
<td>8.528870</td>
|
||||
<td>8.061701</td>
|
||||
<td>9.024450</td>
|
||||
<td>8.532004</td>
|
||||
<td>7.985031</td>
|
||||
<td>9.041575</td>
|
||||
<td>7.928766</td>
|
||||
<td>2010-02-15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>2010-02-20</td>
|
||||
<td>8.270872</td>
|
||||
<td>7.773299</td>
|
||||
<td>8.745526</td>
|
||||
<td>8.274090</td>
|
||||
<td>7.779034</td>
|
||||
<td>8.745627</td>
|
||||
<td>7.745003</td>
|
||||
<td>2010-02-15</td>
|
||||
</tr>
|
||||
|
|
@ -153,7 +161,7 @@ head(df.p)
|
|||
```
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.diagnostics import performance_metrics
|
||||
from prophet.diagnostics import performance_metrics
|
||||
df_p = performance_metrics(df_cv)
|
||||
df_p.head()
|
||||
```
|
||||
|
|
@ -184,6 +192,7 @@ df_p.head()
|
|||
<th>mae</th>
|
||||
<th>mape</th>
|
||||
<th>mdape</th>
|
||||
<th>smape</th>
|
||||
<th>coverage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -191,52 +200,57 @@ df_p.head()
|
|||
<tr>
|
||||
<th>0</th>
|
||||
<td>37 days</td>
|
||||
<td>0.494800</td>
|
||||
<td>0.703420</td>
|
||||
<td>0.505277</td>
|
||||
<td>0.058540</td>
|
||||
<td>0.050149</td>
|
||||
<td>0.676565</td>
|
||||
<td>0.493764</td>
|
||||
<td>0.702683</td>
|
||||
<td>0.504754</td>
|
||||
<td>0.058485</td>
|
||||
<td>0.049922</td>
|
||||
<td>0.058774</td>
|
||||
<td>0.674052</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>38 days</td>
|
||||
<td>0.500706</td>
|
||||
<td>0.707606</td>
|
||||
<td>0.510301</td>
|
||||
<td>0.059120</td>
|
||||
<td>0.049955</td>
|
||||
<td>0.675423</td>
|
||||
<td>0.499522</td>
|
||||
<td>0.706769</td>
|
||||
<td>0.509723</td>
|
||||
<td>0.059060</td>
|
||||
<td>0.049389</td>
|
||||
<td>0.059409</td>
|
||||
<td>0.672910</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>39 days</td>
|
||||
<td>0.522967</td>
|
||||
<td>0.723165</td>
|
||||
<td>0.516433</td>
|
||||
<td>0.059724</td>
|
||||
<td>0.050078</td>
|
||||
<td>0.672682</td>
|
||||
<td>0.521614</td>
|
||||
<td>0.722229</td>
|
||||
<td>0.515793</td>
|
||||
<td>0.059657</td>
|
||||
<td>0.049540</td>
|
||||
<td>0.060131</td>
|
||||
<td>0.670169</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>40 days</td>
|
||||
<td>0.530259</td>
|
||||
<td>0.728189</td>
|
||||
<td>0.519331</td>
|
||||
<td>0.060033</td>
|
||||
<td>0.049706</td>
|
||||
<td>0.678849</td>
|
||||
<td>0.528760</td>
|
||||
<td>0.727159</td>
|
||||
<td>0.518634</td>
|
||||
<td>0.059961</td>
|
||||
<td>0.049232</td>
|
||||
<td>0.060504</td>
|
||||
<td>0.671311</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>41 days</td>
|
||||
<td>0.537736</td>
|
||||
<td>0.733305</td>
|
||||
<td>0.520341</td>
|
||||
<td>0.060114</td>
|
||||
<td>0.049955</td>
|
||||
<td>0.685244</td>
|
||||
<td>0.536078</td>
|
||||
<td>0.732174</td>
|
||||
<td>0.519585</td>
|
||||
<td>0.060036</td>
|
||||
<td>0.049389</td>
|
||||
<td>0.060641</td>
|
||||
<td>0.678849</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -253,11 +267,11 @@ plot_cross_validation_metric(df.cv, metric = 'mape')
|
|||
```
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.plot import plot_cross_validation_metric
|
||||
from prophet.plot import plot_cross_validation_metric
|
||||
fig = plot_cross_validation_metric(df_cv, metric='mape')
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
The size of the rolling window in the figure can be changed with the optional argument `rolling_window`, which specifies the proportion of forecasts to use in each rolling window. The default is 0.1, corresponding to 10% of rows from `df_cv` included in each window; increasing this will lead to a smoother average curve in the figure. The `initial` period should be long enough to capture all of the components of the model, in particular seasonalities and extra regressors: at least a year for yearly seasonality, at least a week for weekly seasonality, etc.
|
||||
|
|
@ -285,7 +299,7 @@ Cross-validation can also be run in parallel mode in Python, by setting specifyi
|
|||
|
||||
|
||||
|
||||
For problems that aren't too big, we recommend using `parallel="processes"`. It will achieve the highest performance when the parallel cross validation can be done on a single machine. For large problems, a [Dask](https://dask.org) cluster can be used to do the cross validation on many machines. You will need to [install Dask](https://docs.dask.org/en/latest/install.html) separately, as it will not be installed with `fbprophet`.
|
||||
For problems that aren't too big, we recommend using `parallel="processes"`. It will achieve the highest performance when the parallel cross validation can be done on a single machine. For large problems, a [Dask](https://dask.org) cluster can be used to do the cross validation on many machines. You will need to [install Dask](https://docs.dask.org/en/latest/install.html) separately, as it will not be installed with `prophet`.
|
||||
|
||||
|
||||
|
||||
|
|
@ -343,22 +357,22 @@ tuning_results['rmse'] = rmses
|
|||
print(tuning_results)
|
||||
```
|
||||
changepoint_prior_scale seasonality_prior_scale rmse
|
||||
0 0.001 0.01 0.757489
|
||||
1 0.001 0.10 0.745049
|
||||
2 0.001 1.00 0.753315
|
||||
3 0.001 10.00 0.763111
|
||||
4 0.010 0.01 0.536260
|
||||
5 0.010 0.10 0.538103
|
||||
6 0.010 1.00 0.544326
|
||||
7 0.010 10.00 0.520970
|
||||
8 0.100 0.01 0.524669
|
||||
9 0.100 0.10 0.521302
|
||||
10 0.100 1.00 0.520692
|
||||
11 0.100 10.00 0.515338
|
||||
12 0.500 0.01 0.532103
|
||||
13 0.500 0.10 0.528939
|
||||
14 0.500 1.00 0.525256
|
||||
15 0.500 10.00 0.524619
|
||||
0 0.001 0.01 0.757694
|
||||
1 0.001 0.10 0.743399
|
||||
2 0.001 1.00 0.753387
|
||||
3 0.001 10.00 0.762890
|
||||
4 0.010 0.01 0.542315
|
||||
5 0.010 0.10 0.535546
|
||||
6 0.010 1.00 0.527008
|
||||
7 0.010 10.00 0.541544
|
||||
8 0.100 0.01 0.524835
|
||||
9 0.100 0.10 0.516061
|
||||
10 0.100 1.00 0.521406
|
||||
11 0.100 10.00 0.518580
|
||||
12 0.500 0.01 0.532140
|
||||
13 0.500 0.10 0.524668
|
||||
14 0.500 1.00 0.521130
|
||||
15 0.500 10.00 0.522980
|
||||
|
||||
|
||||
```python
|
||||
|
|
@ -366,7 +380,7 @@ print(tuning_results)
|
|||
best_params = all_params[np.argmin(rmses)]
|
||||
print(best_params)
|
||||
```
|
||||
{'changepoint_prior_scale': 0.1, 'seasonality_prior_scale': 10.0}
|
||||
{'changepoint_prior_scale': 0.1, 'seasonality_prior_scale': 0.1}
|
||||
|
||||
|
||||
Alternatively, parallelization could be done across parameter combinations by parallelizing the loop above.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ subsections:
|
|||
title: Using Python
|
||||
---
|
||||
|
||||
Prophet has two implementations: [R](#installation-in-r) and [Python](#installation-in-python). Note the slight name difference for the Python package.
|
||||
Prophet has two implementations: [R](#installation-in-r) and [Python](#installation-in-python).
|
||||
|
||||
<a href="#r"></a>
|
||||
|
||||
|
|
@ -37,13 +37,13 @@ Prophet is on PyPI, so you can use pip to install it:
|
|||
|
||||
```
|
||||
# bash
|
||||
# Install pystan with pip before using pip to install fbprophet
|
||||
# Install pystan with pip before using pip to install prophet
|
||||
$ pip install pystan
|
||||
$
|
||||
$ pip install fbprophet
|
||||
$ pip install prophet
|
||||
```
|
||||
|
||||
The major dependency that Prophet has is `pystan`. PyStan has its own [installation instructions](http://pystan.readthedocs.io/en/latest/installation_beginner.html). Install pystan with pip before using pip to install fbprophet.
|
||||
The major dependency that Prophet has is `pystan`. PyStan has its own [installation instructions](http://pystan.readthedocs.io/en/latest/installation_beginner.html). Install pystan with pip before using pip to install prophet.
|
||||
|
||||
After installation, you can [get started!](quick_start.html#python-api)
|
||||
|
||||
|
|
@ -53,8 +53,8 @@ On Windows, PyStan requires a compiler so you'll need to [follow the instruction
|
|||
|
||||
### Linux
|
||||
|
||||
Make sure compilers (gcc, g++, build-essential) and Python development tools (python-dev, python3-dev) are installed. In Red Hat systems, install the packages gcc64 and gcc64-c++. If you are using a VM, be aware that you will need at least 4GB of memory to install fbprophet, and at least 2GB of memory to use fbprophet.
|
||||
Make sure compilers (gcc, g++, build-essential) and Python development tools (python-dev, python3-dev) are installed. In Red Hat systems, install the packages gcc64 and gcc64-c++. If you are using a VM, be aware that you will need at least 4GB of memory to install prophet, and at least 2GB of memory to use prophet.
|
||||
|
||||
### Anaconda
|
||||
|
||||
Use `conda install gcc` to set up gcc. The easiest way to install Prophet is through conda-forge: `conda install -c conda-forge fbprophet`.
|
||||
Use `conda install gcc` to set up gcc. The easiest way to install Prophet is through conda-forge: `conda install -c conda-forge prophet`.
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ m = Prophet(seasonality_mode='multiplicative', mcmc_samples=300).fit(df)
|
|||
fcst = m.predict(future)
|
||||
fig = m.plot_components(fcst)
|
||||
```
|
||||
WARNING:pystan:403 of 600 iterations saturated the maximum tree depth of 10 (67.2 %)
|
||||
WARNING:pystan:481 of 600 iterations saturated the maximum tree depth of 10 (80.2 %)
|
||||
WARNING:pystan:Run again with max_treedepth larger than 10 to avoid saturation
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ First we'll import the data:
|
|||
```python
|
||||
# Python
|
||||
import pandas as pd
|
||||
from fbprophet import Prophet
|
||||
from prophet import Prophet
|
||||
```
|
||||
```python
|
||||
# Python
|
||||
|
|
@ -202,37 +202,37 @@ forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
|
|||
<tr>
|
||||
<th>3265</th>
|
||||
<td>2017-01-15</td>
|
||||
<td>8.204125</td>
|
||||
<td>7.449654</td>
|
||||
<td>8.946255</td>
|
||||
<td>8.211542</td>
|
||||
<td>7.444742</td>
|
||||
<td>8.903545</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3266</th>
|
||||
<td>2017-01-16</td>
|
||||
<td>8.529148</td>
|
||||
<td>7.792752</td>
|
||||
<td>9.284594</td>
|
||||
<td>8.536553</td>
|
||||
<td>7.847804</td>
|
||||
<td>9.211145</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3267</th>
|
||||
<td>2017-01-17</td>
|
||||
<td>8.316555</td>
|
||||
<td>7.563541</td>
|
||||
<td>9.029357</td>
|
||||
<td>8.323968</td>
|
||||
<td>7.541829</td>
|
||||
<td>9.035461</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3268</th>
|
||||
<td>2017-01-18</td>
|
||||
<td>8.149153</td>
|
||||
<td>7.384345</td>
|
||||
<td>8.840279</td>
|
||||
<td>8.156621</td>
|
||||
<td>7.404457</td>
|
||||
<td>8.830642</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3269</th>
|
||||
<td>2017-01-19</td>
|
||||
<td>8.161075</td>
|
||||
<td>7.430352</td>
|
||||
<td>8.859482</td>
|
||||
<td>8.168561</td>
|
||||
<td>7.438865</td>
|
||||
<td>8.908668</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -262,12 +262,12 @@ fig2 = m.plot_components(forecast)
|
|||

|
||||
|
||||
|
||||
An interactive figure of the forecast and components can be created with plotly. You will need to install plotly 4.0 or above separately, as it will not by default be installed with fbprophet. You will also need to install the `notebook` and `ipywidgets` packages.
|
||||
An interactive figure of the forecast and components can be created with plotly. You will need to install plotly 4.0 or above separately, as it will not by default be installed with prophet. You will also need to install the `notebook` and `ipywidgets` packages.
|
||||
|
||||
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.plot import plot_plotly, plot_components_plotly
|
||||
from prophet.plot import plot_plotly, plot_components_plotly
|
||||
|
||||
plot_plotly(m, forecast)
|
||||
```
|
||||
|
|
@ -291,6 +291,12 @@ In R, we use the normal model fitting API. We provide a `prophet` function that
|
|||
# R
|
||||
library(prophet)
|
||||
```
|
||||
R[write to console]: Loading required package: Rcpp
|
||||
|
||||
R[write to console]: Loading required package: rlang
|
||||
|
||||
|
||||
|
||||
First we read in the data and create the outcome variable. As in the Python API, this is a dataframe with columns `ds` and `y`, containing the date and numeric value respectively. The ds column should be YYYY-MM-DD for a date, or YYYY-MM-DD HH:MM:SS for a timestamp. As above, we use here the log number of views to Peyton Manning's Wikipedia page, available [here](https://github.com/facebook/prophet/blob/master/examples/example_wp_log_peyton_manning.csv).
|
||||
|
||||
|
||||
|
|
@ -313,7 +319,6 @@ Predictions are made on a dataframe with a column `ds` containing the dates for
|
|||
future <- make_future_dataframe(m, periods = 365)
|
||||
tail(future)
|
||||
```
|
||||
|
||||
ds
|
||||
3265 2017-01-14
|
||||
3266 2017-01-15
|
||||
|
|
@ -323,7 +328,6 @@ tail(future)
|
|||
3270 2017-01-19
|
||||
|
||||
|
||||
|
||||
As with most modeling procedures in R, we use the generic `predict` function to get our forecast. The `forecast` object is a dataframe with a column `yhat` containing the forecast. It has additional columns for uncertainty intervals and seasonal components.
|
||||
|
||||
|
||||
|
|
@ -332,15 +336,13 @@ As with most modeling procedures in R, we use the generic `predict` function to
|
|||
forecast <- predict(m, future)
|
||||
tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')])
|
||||
```
|
||||
|
||||
ds yhat yhat_lower yhat_upper
|
||||
3265 2017-01-14 7.824163 7.127881 8.609668
|
||||
3266 2017-01-15 8.205942 7.452071 8.904387
|
||||
3267 2017-01-16 8.530942 7.742400 9.300974
|
||||
3268 2017-01-17 8.318327 7.606534 9.071184
|
||||
3269 2017-01-18 8.150948 7.440224 8.902922
|
||||
3270 2017-01-19 8.162839 7.385953 8.890669
|
||||
|
||||
3265 2017-01-14 7.818359 7.071228 8.550957
|
||||
3266 2017-01-15 8.200125 7.475725 8.869495
|
||||
3267 2017-01-16 8.525104 7.747071 9.226915
|
||||
3268 2017-01-17 8.312482 7.551904 9.046774
|
||||
3269 2017-01-18 8.145098 7.390770 8.863692
|
||||
3270 2017-01-19 8.156964 7.381716 8.866507
|
||||
|
||||
|
||||
You can use the generic `plot` function to plot the forecast, by passing in the model and the forecast dataframe.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ subsections:
|
|||
id: prior-scale-for-holidays-and-seasonality
|
||||
- title: Additional regressors
|
||||
id: additional-regressors
|
||||
- title: Coefficients of additional regressors
|
||||
id: coefficients-of-additional-regressors
|
||||
---
|
||||
<a id="modeling-holidays-and-special-events"> </a>
|
||||
|
||||
|
|
@ -97,8 +99,8 @@ The holiday effect can be seen in the `forecast` dataframe:
|
|||
|
||||
```R
|
||||
# R
|
||||
forecast %>%
|
||||
select(ds, playoff, superbowl) %>%
|
||||
forecast %>%
|
||||
select(ds, playoff, superbowl) %>%
|
||||
filter(abs(playoff + superbowl) > 0) %>%
|
||||
tail(10)
|
||||
```
|
||||
|
|
@ -137,62 +139,62 @@ forecast[(forecast['playoff'] + forecast['superbowl']).abs() > 0][
|
|||
<tr>
|
||||
<th>2190</th>
|
||||
<td>2014-02-02</td>
|
||||
<td>1.217571</td>
|
||||
<td>1.230312</td>
|
||||
<td>1.223965</td>
|
||||
<td>1.201517</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2191</th>
|
||||
<td>2014-02-03</td>
|
||||
<td>1.898042</td>
|
||||
<td>1.466063</td>
|
||||
<td>1.901742</td>
|
||||
<td>1.460471</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2532</th>
|
||||
<td>2015-01-11</td>
|
||||
<td>1.217571</td>
|
||||
<td>1.223965</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2533</th>
|
||||
<td>2015-01-12</td>
|
||||
<td>1.898042</td>
|
||||
<td>1.901742</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2901</th>
|
||||
<td>2016-01-17</td>
|
||||
<td>1.217571</td>
|
||||
<td>1.223965</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2902</th>
|
||||
<td>2016-01-18</td>
|
||||
<td>1.898042</td>
|
||||
<td>1.901742</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2908</th>
|
||||
<td>2016-01-24</td>
|
||||
<td>1.217571</td>
|
||||
<td>1.223965</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2909</th>
|
||||
<td>2016-01-25</td>
|
||||
<td>1.898042</td>
|
||||
<td>1.901742</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2922</th>
|
||||
<td>2016-02-07</td>
|
||||
<td>1.217571</td>
|
||||
<td>1.230312</td>
|
||||
<td>1.223965</td>
|
||||
<td>1.201517</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2923</th>
|
||||
<td>2016-02-08</td>
|
||||
<td>1.898042</td>
|
||||
<td>1.466063</td>
|
||||
<td>1.901742</td>
|
||||
<td>1.460471</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -211,11 +213,11 @@ prophet_plot_components(m, forecast)
|
|||
# Python
|
||||
fig = m.plot_components(forecast)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
Individual holidays can be plotted using the `plot_forecast_component` function (imported from `fbprophet.plot` in Python) like `plot_forecast_component(m, forecast, 'superbowl')` to plot just the superbowl holiday component.
|
||||
Individual holidays can be plotted using the `plot_forecast_component` function (imported from `prophet.plot` in Python) like `plot_forecast_component(m, forecast, 'superbowl')` to plot just the superbowl holiday component.
|
||||
|
||||
|
||||
<a id="built-in-country-holidays"> </a>
|
||||
|
|
@ -246,16 +248,14 @@ You can see which holidays were included by looking at the `train_holiday_names`
|
|||
# R
|
||||
m$train.holiday.names
|
||||
```
|
||||
|
||||
[1] "playoff" "superbowl"
|
||||
[3] "New Year's Day" "Martin Luther King, Jr. Day"
|
||||
[5] "Washington's Birthday" "Memorial Day"
|
||||
[7] "Independence Day" "Labor Day"
|
||||
[9] "Columbus Day" "Veterans Day"
|
||||
[11] "Veterans Day (Observed)" "Thanksgiving"
|
||||
[1] "playoff" "superbowl"
|
||||
[3] "New Year's Day" "Martin Luther King Jr. Day"
|
||||
[5] "Washington's Birthday" "Memorial Day"
|
||||
[7] "Independence Day" "Labor Day"
|
||||
[9] "Columbus Day" "Veterans Day"
|
||||
[11] "Veterans Day (Observed)" "Thanksgiving"
|
||||
[13] "Christmas Day" "Independence Day (Observed)"
|
||||
[15] "Christmas Day (Observed)" "New Year's Day (Observed)"
|
||||
|
||||
[15] "Christmas Day (Observed)" "New Year's Day (Observed)"
|
||||
|
||||
|
||||
```python
|
||||
|
|
@ -268,7 +268,7 @@ m.train_holiday_names
|
|||
0 playoff
|
||||
1 superbowl
|
||||
2 New Year's Day
|
||||
3 Martin Luther King, Jr. Day
|
||||
3 Martin Luther King Jr. Day
|
||||
4 Washington's Birthday
|
||||
5 Memorial Day
|
||||
6 Independence Day
|
||||
|
|
@ -306,8 +306,8 @@ prophet_plot_components(m, forecast)
|
|||
forecast = m.predict(future)
|
||||
fig = m.plot_components(forecast)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
<a id="fourier-order-for-seasonalities"> </a>
|
||||
|
|
@ -316,7 +316,7 @@ fig = m.plot_components(forecast)
|
|||
|
||||
|
||||
|
||||
Seasonalities are estimated using a partial Fourier sum. See [the paper](https://peerj.com/preprints/3190/) for complete details, and [this figure on Wikipedia](https://en.wikipedia.org/wiki/Fourier_series#/media/File:Fourier_Series.svg) for an illustration of how a partial Fourier sum can approximate an aribtrary periodic signal. The number of terms in the partial sum (the order) is a parameter that determines how quickly the seasonality can change. To illustrate this, consider the Peyton Manning data from the [Quickstart](https://facebook.github.io/prophet/docs/quick_start.html). The default Fourier order for yearly seasonality is 10, which produces this fit:
|
||||
Seasonalities are estimated using a partial Fourier sum. See [the paper](https://peerj.com/preprints/3190/) for complete details, and [this figure on Wikipedia](https://en.wikipedia.org/wiki/Fourier_series#/media/File:Fourier_Series.svg) for an illustration of how a partial Fourier sum can approximate an arbitrary periodic signal. The number of terms in the partial sum (the order) is a parameter that determines how quickly the seasonality can change. To illustrate this, consider the Peyton Manning data from the [Quickstart](https://facebook.github.io/prophet/docs/quick_start.html). The default Fourier order for yearly seasonality is 10, which produces this fit:
|
||||
|
||||
|
||||
```R
|
||||
|
|
@ -326,12 +326,12 @@ prophet:::plot_yearly(m)
|
|||
```
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.plot import plot_yearly
|
||||
from prophet.plot import plot_yearly
|
||||
m = Prophet().fit(df)
|
||||
a = plot_yearly(m)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
The default values are often appropriate, but they can be increased when the seasonality needs to fit higher-frequency changes, and generally be less smooth. The Fourier order can be specified for each built-in seasonality when instantiating the model, here it is increased to 20:
|
||||
|
|
@ -344,12 +344,12 @@ prophet:::plot_yearly(m)
|
|||
```
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.plot import plot_yearly
|
||||
from prophet.plot import plot_yearly
|
||||
m = Prophet(yearly_seasonality=20).fit(df)
|
||||
a = plot_yearly(m)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
Increasing the number of Fourier terms allows the seasonality to fit faster changing cycles, but can also lead to overfitting: N Fourier terms corresponds to 2N variables used for modeling the cycle
|
||||
|
|
@ -388,8 +388,8 @@ m.add_seasonality(name='monthly', period=30.5, fourier_order=5)
|
|||
forecast = m.fit(df).predict(future)
|
||||
fig = m.plot_components(forecast)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
<a id="seasonalities-that-depend-on-other-factors"> </a>
|
||||
|
|
@ -452,8 +452,8 @@ future['off_season'] = ~future['ds'].apply(is_nfl_season)
|
|||
forecast = m.fit(df).predict(future)
|
||||
fig = m.plot_components(forecast)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
Both of the seasonalities now show up in the components plots above. We can see that during the on-season when games are played every Sunday, there are large increases on Sunday and Monday that are completely absent during the off-season.
|
||||
|
|
@ -470,8 +470,8 @@ If you find that the holidays are overfitting, you can adjust their prior scale
|
|||
# R
|
||||
m <- prophet(df, holidays = holidays, holidays.prior.scale = 0.05)
|
||||
forecast <- predict(m, future)
|
||||
forecast %>%
|
||||
select(ds, playoff, superbowl) %>%
|
||||
forecast %>%
|
||||
select(ds, playoff, superbowl) %>%
|
||||
filter(abs(playoff + superbowl) > 0) %>%
|
||||
tail(10)
|
||||
```
|
||||
|
|
@ -512,62 +512,62 @@ forecast[(forecast['playoff'] + forecast['superbowl']).abs() > 0][
|
|||
<tr>
|
||||
<th>2190</th>
|
||||
<td>2014-02-02</td>
|
||||
<td>1.205344</td>
|
||||
<td>0.963327</td>
|
||||
<td>1.206086</td>
|
||||
<td>0.964914</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2191</th>
|
||||
<td>2014-02-03</td>
|
||||
<td>1.851992</td>
|
||||
<td>0.991010</td>
|
||||
<td>1.852077</td>
|
||||
<td>0.992634</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2532</th>
|
||||
<td>2015-01-11</td>
|
||||
<td>1.205344</td>
|
||||
<td>1.206086</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2533</th>
|
||||
<td>2015-01-12</td>
|
||||
<td>1.851992</td>
|
||||
<td>1.852077</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2901</th>
|
||||
<td>2016-01-17</td>
|
||||
<td>1.205344</td>
|
||||
<td>1.206086</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2902</th>
|
||||
<td>2016-01-18</td>
|
||||
<td>1.851992</td>
|
||||
<td>1.852077</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2908</th>
|
||||
<td>2016-01-24</td>
|
||||
<td>1.205344</td>
|
||||
<td>1.206086</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2909</th>
|
||||
<td>2016-01-25</td>
|
||||
<td>1.851992</td>
|
||||
<td>1.852077</td>
|
||||
<td>0.000000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2922</th>
|
||||
<td>2016-02-07</td>
|
||||
<td>1.205344</td>
|
||||
<td>0.963327</td>
|
||||
<td>1.206086</td>
|
||||
<td>0.964914</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2923</th>
|
||||
<td>2016-02-08</td>
|
||||
<td>1.851992</td>
|
||||
<td>0.991010</td>
|
||||
<td>1.852077</td>
|
||||
<td>0.992634</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -640,8 +640,8 @@ future['nfl_sunday'] = future['ds'].apply(nfl_sunday)
|
|||
forecast = m.predict(future)
|
||||
fig = m.plot_components(forecast)
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
NFL Sundays could also have been handled using the "holidays" interface described above, by creating a list of past and future NFL Sundays. The `add_regressor` function provides a more general interface for defining extra linear regressors, and in particular does not require that the regressor be a binary indicator. Another time series could be used as a regressor, although its future values would have to be known.
|
||||
|
|
@ -662,6 +662,13 @@ The extra regressor must be known for both the history and for future dates. It
|
|||
|
||||
Extra regressors are put in the linear component of the model, so the underlying model is that the time series depends on the extra regressor as either an additive or multiplicative factor (see the next section for multiplicativity).
|
||||
|
||||
|
||||
|
||||
<a id="coefficients-of-additional-regressors"> </a>
|
||||
|
||||
#### Coefficients of additional regressors
|
||||
|
||||
To extract the beta coefficients of the extra regressors, use the utility function `regressor_coefficients` (`from fbprophet.utilities import regressor_coefficients` in Python, `prophet::regressor_coefficients` in R) on the fitted model. The estimated beta coefficient for each regressor roughly represents the increase in prediction value for a unit increase in the regressor value (note that the coefficients returned are always on the scale of the original data). If `mcmc_samples` is specified, a credible interval for each coefficient is also returned, which can help identify whether each regressor is "statistically significant".
|
||||
|
||||
|
||||
To extract the beta coefficients of the extra regressors, use the utility function `regressor_coefficients` (`from prophet.utilities import regressor_coefficients` in Python, `prophet::regressor_coefficients` in R) on the fitted model. The estimated beta coefficient for each regressor roughly represents the increase in prediction value for a unit increase in the regressor value (note that the coefficients returned are always on the scale of the original data). If `mcmc_samples` is specified, a credible interval for each coefficient is also returned, which can help identify whether each regressor is "statistically significant".
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@ You may have noticed in the earlier examples in this documentation that real tim
|
|||
Prophet detects changepoints by first specifying a large number of *potential changepoints* at which the rate is allowed to change. It then puts a sparse prior on the magnitudes of the rate changes (equivalent to L1 regularization) - this essentially means that Prophet has a large number of *possible* places where the rate can change, but will use as few of them as possible. Consider the Peyton Manning forecast from the Quickstart. By default, Prophet specifies 25 potential changepoints which are uniformly placed in the first 80% of the time series. The vertical lines in this figure indicate where the potential changepoints were placed:
|
||||
|
||||
|
||||
INFO:numexpr.utils:NumExpr defaulting to 8 threads.
|
||||
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
Even though we have a lot of places where the rate can possibly change, because of the sparse prior, most of these changepoints go unused. We can see this by plotting the magnitude of the rate change at each changepoint:
|
||||
|
|
@ -41,7 +44,7 @@ plot(m, forecast) + add_changepoints_to_plot(m)
|
|||
```
|
||||
```python
|
||||
# Python
|
||||
from fbprophet.plot import add_changepoints_to_plot
|
||||
from prophet.plot import add_changepoints_to_plot
|
||||
fig = m.plot(forecast)
|
||||
a = add_changepoints_to_plot(fig.gca(), m, forecast)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ prophet_plot_components(m, forecast)
|
|||
fig = m.plot_components(forecast)
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
You can access the raw posterior predictive samples in Python using the method `m.predictive_samples(future)`, or in R using the function `predictive_samples(m, future)`.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ id: home
|
|||
|
||||
Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.
|
||||
|
||||
Prophet is [open source software](https://code.facebook.com/projects/) released by Facebook's [Core Data Science team](https://research.fb.com/category/data-science/). It is available for download on [CRAN](https://cran.r-project.org/package=prophet) and [PyPI](https://pypi.python.org/pypi/fbprophet/).
|
||||
Prophet is [open source software](https://code.facebook.com/projects/) released by Facebook's [Core Data Science team](https://research.fb.com/category/data-science/). It is available for download on [CRAN](https://cran.r-project.org/package=prophet) and [PyPI](https://pypi.python.org/pypi/prophet/).
|
||||
|
||||
{% include content/gridblocks.html data_source=site.data.features layout="fourColumn" align="left" %}
|
||||
|
|
|
|||
BIN
docs/static/diagnostics_files/diagnostics_15_0.png
vendored
|
Before Width: | Height: | Size: 67 KiB |
BIN
docs/static/diagnostics_files/diagnostics_16_0.png
vendored
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 66 KiB |
BIN
docs/static/diagnostics_files/diagnostics_17_0.png
vendored
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
docs/static/diagnostics_files/diagnostics_3_0.png
vendored
|
Before Width: | Height: | Size: 52 KiB |
BIN
docs/static/diagnostics_files/diagnostics_4_0.png
vendored
Normal file
|
After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 29 KiB |
BIN
docs/static/non-daily_data_files/non-daily_data_18_2.png
vendored
Normal file
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 75 KiB |
BIN
docs/static/outliers_files/outliers_10_0.png
vendored
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
BIN
docs/static/outliers_files/outliers_12_1.png
vendored
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 48 KiB |
BIN
docs/static/outliers_files/outliers_13_0.png
vendored
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 74 KiB |
BIN
docs/static/outliers_files/outliers_3_1.png
vendored
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 24 KiB |
BIN
docs/static/outliers_files/outliers_4_0.png
vendored
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 37 KiB |
BIN
docs/static/outliers_files/outliers_6_1.png
vendored
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
BIN
docs/static/outliers_files/outliers_7_0.png
vendored
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 75 KiB |
BIN
docs/static/outliers_files/outliers_9_1.png
vendored
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
BIN
docs/static/quick_start_files/quick_start_12_0.png
vendored
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 102 KiB |
BIN
docs/static/quick_start_files/quick_start_14_0.png
vendored
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 52 KiB |
BIN
docs/static/quick_start_files/quick_start_30_0.png
vendored
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 84 KiB |
BIN
docs/static/quick_start_files/quick_start_32_0.png
vendored
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 106 KiB |
BIN
docs/static/trend_changepoints_files/trend_changepoints_4_1.png
vendored
Normal file
|
After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 24 KiB |
BIN
docs/static/uncertainty_intervals_files/uncertainty_intervals_11_0.png
vendored
Normal file
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
|
@ -151,7 +151,9 @@
|
|||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"output_hidden": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
|
|
|
|||