A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.
2023 Update: We discuss our plans for the future of Prophet in this blog post: facebook/prophet in 2023 and beyond
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 released by Facebook's Core Data Science team. It is available for download on CRAN and PyPI.
⚠️ The CRAN version of prophet is fairly outdated. To get the latest bug fixes and updated country holiday data, we suggest installing the latest release.
Prophet is a CRAN package so
you can use install.packages
.
install.packages('prophet')
After installation, you can get started!
install.packages('remotes')
::install_github('facebook/prophet@*release', subdir = 'R') remotes
You can also choose an experimental alternative stan backend called
cmdstanr
. Once you've installed prophet
,
follow these instructions to use cmdstanr
instead of
rstan
as the backend:
# R
# We recommend running this in a fresh R session or restarting your current session
install.packages(c("cmdstanr", "posterior"), repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
# If you haven't installed cmdstan before, run:
::install_cmdstan()
cmdstanr# Otherwise, you can point cmdstanr to your cmdstan path:
::set_cmdstan_path(path = <your existing cmdstan>)
cmdstanr
# Set the R_STAN_BACKEND environment variable
Sys.setenv(R_STAN_BACKEND = "CMDSTANR")
On Windows, R requires a compiler so you'll need to follow
the instructions provided by rstan
. The key step is
installing Rtools before
attempting to install the package.
If you have custom Stan compiler settings, install from source rather than the CRAN binary.
Prophet is on PyPI, so you can use pip
to install
it.
python -m pip install prophet
After installation, you can get started!
Prophet can also be installed through conda-forge.
conda install -c conda-forge prophet
To get the latest code changes as they are merged, you can clone this repo and build from source manually. This is not guaranteed to be stable.
git clone https://github.com/facebook/prophet.git
cd prophet/python
python -m pip install -e .
By default, Prophet will use a fixed version of cmdstan
(downloading and installing it if necessary) to compile the model
executables. If this is undesired and you would like to use your own
existing cmdstan
installation, you can set the environment
variable PROPHET_REPACKAGE_CMDSTAN
to
False
:
export PROPHET_REPACKAGE_CMDSTAN=False; python -m pip install -e .
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.
Using cmdstanpy
with Windows requires a Unix-compatible
C compiler such as mingw-gcc. If cmdstanpy is installed first, one can
be installed via the cmdstanpy.install_cxx_toolchain
command.
y
the history, zero division error in cross validation metrics.NDArray[np.float_]
to
NDArray[np.float64]
to be compatible with numpy 2.0holidays
data based on holidays version
0.57.scaling
to the Prophet()
instantiation. Allows minmax
scaling on y
instead of absmax
scaling (dividing by the maximum value).
scaling='absmax'
by default, preserving the behaviour of
previous versions.holidays_mode
to the
Prophet()
instantiation. Allows holidays regressors to have
a different mode than seasonality regressors. holidays_mode
takes the same value as seasonality_mode
if not specified,
preserving the behaviour of previous versions.Prophet
object:
preprocess()
and calculate_initial_params()
.
These do not need to be called and will not change the model fitting
process. Their purpose is to provide clarity on the pre-processing steps
taken (y
scaling, creating fourier series, regressor
scaling, setting changepoints, etc.) before the data is passed to the
stan model.extra_output_columns
to
cross_validation()
. The user can specify additional columns
from predict()
to include in the final output alongside
ds
and yhat
, for example
extra_output_columns=['trend']
.hdays
module was deprecated last
version and is now removed.holidays
data based on holidays version
0.34.holidays
package for country
holidays.holidays
data based on holidays version
0.25..predict()
by up to 10x by removing
intermediate DataFrame creations.train()
and predict()
pipelines.construct_holiday_dataframe()
holidays
data based on holidays version
0.18.pystan2
dependency with cmdstan
+
cmdstanpy
.stan
model code, cross-validation
metric calculations, holidays.holidays
and
pandas
holidays
and
pandas
packages.cmdstanpy
backend now available in PythonProphet is licensed under the MIT license.