Prophet Forecasting
Use this skill after forecasting-data-prep. Prophet is best for one target series at a time with interpretable trend, multiple seasonalities, holidays/events, and optional known-future regressors. It is not a native panel, hierarchical, ARIMA, ETS, or neural forecasting library.
Minimum Install
Python:
python -m pip install prophet
R:
install.packages("prophet")
Python package name is prophet; older fbprophet imports are pre-v1.0.
Data Contract
- Required columns:
ds datestamp and numeric y.
ds must parse as date/timestamp; Python Prophet does not support timezone-aware ds, so convert to one timezone and remove tz before fitting.
- One model forecasts one target. For multiple series, fit separate Prophet models per series or aggregate before modeling.
- For
growth="logistic", both history and future dataframes require cap; if using a saturating minimum, also provide floor.
- Every extra regressor and conditional seasonality column must be present in both fit and predict dataframes.
Run the bundled schema checker when converting prepared data:
python prophet-forecasting/scripts/prophet_contract_check.py data.csv \
--regressors promo,price \
--growth logistic \
--freq D
Supported Model Choices
Prophet(growth="linear"): default piecewise linear trend.
Prophet(growth="logistic"): saturating growth with cap, optional floor.
Prophet(growth="flat"): flat trend for strong-seasonality or known-regressor/counterfactual use cases.
- Built-in yearly, weekly, and daily seasonality can be
auto, enabled/disabled, or set to a Fourier order.
- Use
add_seasonality(name, period, fourier_order, ...) for documented custom seasonalities.
- Use
seasonality_mode="additive" or "multiplicative"; individual seasonalities/regressors can override mode.
- Custom trend functions beyond linear/logistic/flat require modifying Prophet source; do not invent a constructor option for them.
Modeling Workflow
- Prepare data with
forecasting-data-prep; preserve freq, horizon, cutoffs, known-future covariates, and excluded leaky columns.
- Rename selected time and target columns to
ds and y; sort by ds; remove duplicate ds rows.
- Split by temporal cutoff before fitting transformations. Never random split.
- Add holidays/events only if their future dates are known or intentionally omitted for one-off shocks.
- Add regressors only when future values are available for the prediction dataframe. Use lagged/rolling regressors only if built from past data before the cutoff.
- Fit:
m = Prophet(...); m.add_regressor(...); m.fit(train_df).
- Predict with either
m.make_future_dataframe(periods=horizon, freq=freq) plus required future columns, or a hand-built future dataframe matching the forecast dates.
- Evaluate with temporal holdout or Prophet
cross_validation; use test only once for final reporting.
Python Pattern
from prophet import Prophet
train = train.rename(columns={time_col: "ds", target_col: "y"})
future = future.rename(columns={time_col: "ds"})
m = Prophet(
growth="linear",
seasonality_mode="additive",
interval_width=0.8,
)
for col in known_future_regressors:
m.add_regressor(col)
m.fit(train[["ds", "y", *known_future_regressors]])
forecast = m.predict(future[["ds", *known_future_regressors]])
forecast[["ds", "yhat", "yhat_lower", "yhat_upper"]]
Use make_future_dataframe(periods=horizon, freq=freq) only when its generated dates exactly match the required horizon and valid timestamps. For monthly data, forecast monthly with a pandas offset such as MS, not daily.
Validation and Diagnostics
- Prophet cross-validation:
from prophet.diagnostics import cross_validation, performance_metrics.
- Set
initial, period, and horizon as pandas Timedelta strings in Python, or pass explicit cutoffs.
- Official metrics include MSE, RMSE, MAE, MAPE, MDAPE, sMAPE, and interval coverage; add MASE/WAPE externally when scale comparison or demand planning needs it.
- Plots:
m.plot(forecast), m.plot_components(forecast), plot_plotly, plot_components_plotly, and add_changepoints_to_plot.
- Inspect uncertainty: default intervals cover trend uncertainty and observation noise; use
mcmc_samples > 0 for full Bayesian sampling and seasonality uncertainty when justified by runtime.
- For debugging Python preprocessing, use
m.preprocess(df) and m.calculate_initial_params() when available in the installed version.
Anti-Leakage Rules
- Never random split.
- Fit scalers, imputers, encoders, outlier thresholds, and target transforms on train only.
- Recompute lags/rolling features per cutoff using only past information.
- Do not use future regressors unless they are actually known at prediction time for every horizon step.
- Respect
freq, horizon, valid timestamp windows, and any gap between train end and forecast start.
- During backtesting, rebuild the future dataframe and all regressors from each fold cutoff.
Common Errors
- Passing non-
ds/y column names directly to Prophet.
- Leaving timezone-aware timestamps in Python
ds.
- Asking for daily forecasts from monthly data or for timestamps outside regular observed windows.
- Adding a regressor after fitting, omitting it from
future, or leaving nulls in regressor columns.
- Using
growth="logistic" without cap in both history and future, or with cap <= floor.
- Treating Prophet as native multivariate/panel forecasting; use one model per target series.
- Pickling Python models; use Prophet JSON serialization instead.
References
- Read
references/prophet-data-and-features.md for data schema, holidays, regressors, growth, and frequency details.
- Read
references/prophet-validation-diagnostics.md for cross-validation, metrics, uncertainty, plotting, outliers, and limitations.
- Read
references/official-sources.md for official documentation sources consulted.
Ready Checklist
forecasting-data-prep contract exists and all leakage risks are resolved or documented.
- Prophet dataframe has
ds, y, one row per timestamp, no timezone-aware ds, numeric finite y.
- Frequency and horizon match Prophet future dates.
- Holidays/events and regressors are known for the forecast horizon or excluded.
- Validation uses temporal cutoffs/backtesting, not random split.
- Forecast output includes
yhat, intervals, component plots, and appropriate temporal metrics.
1---2name: prophet-forecasting3description: Use Prophet for univariate forecasting with trend, seasonality, holidays, extra regressors, uncertainty intervals, temporal cross-validation, and diagnostic plots. Trigger this skill when an agent needs to model a prepared time-series dataset with the official Python or R Prophet library, after first applying forecasting-data-prep to validate frequency, horizon, covariate availability, temporal splits, and anti-leakage safeguards.4---56# Prophet Forecasting78Use this skill after `forecasting-data-prep`. Prophet is best for one target series at a time with interpretable trend, multiple seasonalities, holidays/events, and optional known-future regressors. It is not a native panel, hierarchical, ARIMA, ETS, or neural forecasting library.910## Minimum Install1112Python:1314```bash15python -m pip install prophet16```1718R:1920```r21install.packages("prophet")22```2324Python package name is `prophet`; older `fbprophet` imports are pre-v1.0.2526## Data Contract2728- Required columns: `ds` datestamp and numeric `y`.29- `ds` must parse as date/timestamp; Python Prophet does not support timezone-aware `ds`, so convert to one timezone and remove tz before fitting.30- One model forecasts one target. For multiple series, fit separate Prophet models per series or aggregate before modeling.31- For `growth="logistic"`, both history and future dataframes require `cap`; if using a saturating minimum, also provide `floor`.32- Every extra regressor and conditional seasonality column must be present in both fit and predict dataframes.3334Run the bundled schema checker when converting prepared data:3536```bash37python prophet-forecasting/scripts/prophet_contract_check.py data.csv \38 --regressors promo,price \39 --growth logistic \40 --freq D41```4243## Supported Model Choices4445- `Prophet(growth="linear")`: default piecewise linear trend.46- `Prophet(growth="logistic")`: saturating growth with `cap`, optional `floor`.47- `Prophet(growth="flat")`: flat trend for strong-seasonality or known-regressor/counterfactual use cases.48- Built-in yearly, weekly, and daily seasonality can be `auto`, enabled/disabled, or set to a Fourier order.49- Use `add_seasonality(name, period, fourier_order, ...)` for documented custom seasonalities.50- Use `seasonality_mode="additive"` or `"multiplicative"`; individual seasonalities/regressors can override `mode`.51- Custom trend functions beyond linear/logistic/flat require modifying Prophet source; do not invent a constructor option for them.5253## Modeling Workflow54551. Prepare data with `forecasting-data-prep`; preserve `freq`, horizon, cutoffs, known-future covariates, and excluded leaky columns.562. Rename selected time and target columns to `ds` and `y`; sort by `ds`; remove duplicate `ds` rows.573. Split by temporal cutoff before fitting transformations. Never random split.584. Add holidays/events only if their future dates are known or intentionally omitted for one-off shocks.595. Add regressors only when future values are available for the prediction dataframe. Use lagged/rolling regressors only if built from past data before the cutoff.606. Fit: `m = Prophet(...); m.add_regressor(...); m.fit(train_df)`.617. Predict with either `m.make_future_dataframe(periods=horizon, freq=freq)` plus required future columns, or a hand-built future dataframe matching the forecast dates.628. Evaluate with temporal holdout or Prophet `cross_validation`; use test only once for final reporting.6364## Python Pattern6566```python67from prophet import Prophet6869train = train.rename(columns={time_col: "ds", target_col: "y"})70future = future.rename(columns={time_col: "ds"})7172m = Prophet(73 growth="linear",74 seasonality_mode="additive",75 interval_width=0.8,76)77for col in known_future_regressors:78 m.add_regressor(col)7980m.fit(train[["ds", "y", *known_future_regressors]])81forecast = m.predict(future[["ds", *known_future_regressors]])82forecast[["ds", "yhat", "yhat_lower", "yhat_upper"]]83```8485Use `make_future_dataframe(periods=horizon, freq=freq)` only when its generated dates exactly match the required horizon and valid timestamps. For monthly data, forecast monthly with a pandas offset such as `MS`, not daily.8687## Validation and Diagnostics8889- Prophet cross-validation: `from prophet.diagnostics import cross_validation, performance_metrics`.90- Set `initial`, `period`, and `horizon` as pandas Timedelta strings in Python, or pass explicit `cutoffs`.91- Official metrics include MSE, RMSE, MAE, MAPE, MDAPE, sMAPE, and interval coverage; add MASE/WAPE externally when scale comparison or demand planning needs it.92- Plots: `m.plot(forecast)`, `m.plot_components(forecast)`, `plot_plotly`, `plot_components_plotly`, and `add_changepoints_to_plot`.93- Inspect uncertainty: default intervals cover trend uncertainty and observation noise; use `mcmc_samples > 0` for full Bayesian sampling and seasonality uncertainty when justified by runtime.94- For debugging Python preprocessing, use `m.preprocess(df)` and `m.calculate_initial_params()` when available in the installed version.9596## Anti-Leakage Rules9798- Never random split.99- Fit scalers, imputers, encoders, outlier thresholds, and target transforms on train only.100- Recompute lags/rolling features per cutoff using only past information.101- Do not use future regressors unless they are actually known at prediction time for every horizon step.102- Respect `freq`, horizon, valid timestamp windows, and any gap between train end and forecast start.103- During backtesting, rebuild the future dataframe and all regressors from each fold cutoff.104105## Common Errors106107- Passing non-`ds`/`y` column names directly to Prophet.108- Leaving timezone-aware timestamps in Python `ds`.109- Asking for daily forecasts from monthly data or for timestamps outside regular observed windows.110- Adding a regressor after fitting, omitting it from `future`, or leaving nulls in regressor columns.111- Using `growth="logistic"` without `cap` in both history and future, or with `cap <= floor`.112- Treating Prophet as native multivariate/panel forecasting; use one model per target series.113- Pickling Python models; use Prophet JSON serialization instead.114115## References116117- Read `references/prophet-data-and-features.md` for data schema, holidays, regressors, growth, and frequency details.118- Read `references/prophet-validation-diagnostics.md` for cross-validation, metrics, uncertainty, plotting, outliers, and limitations.119- Read `references/official-sources.md` for official documentation sources consulted.120121## Ready Checklist122123- `forecasting-data-prep` contract exists and all leakage risks are resolved or documented.124- Prophet dataframe has `ds`, `y`, one row per timestamp, no timezone-aware `ds`, numeric finite `y`.125- Frequency and horizon match Prophet future dates.126- Holidays/events and regressors are known for the forecast horizon or excluded.127- Validation uses temporal cutoffs/backtesting, not random split.128- Forecast output includes `yhat`, intervals, component plots, and appropriate temporal metrics.