Prophet Forecasting
Easy API Python

Time Series Forecasting with Prophet

Learn how to use Prophet to quickly build forecasts that handle trend, seasonality, and holidays with minimal configuration.

What is Prophet?

Prophet is a library originally open-sourced by Facebook for forecasting time series that have strong seasonal patterns and missing data.

  • Additive model: Trend + Seasonality + Holidays.
  • Simple DataFrame API: columns ds (date) and y (value).

Example: Daily Forecast

Basic Prophet Workflow
# pip install prophet  (or: pip install fbprophet for older versions)

import pandas as pd
import numpy as np
from prophet import Prophet
import matplotlib.pyplot as plt

# Create example daily time series
dates = pd.date_range(start="2020-01-01", periods=200, freq="D")
np.random.seed(42)
values = 100 + np.arange(200) * 0.2 + 10 * np.sin(2 * np.pi * dates.dayofyear / 365) + np.random.normal(scale=3, size=200)

df = pd.DataFrame({
    "ds": dates,
    "y": values
})

model = Prophet(daily_seasonality=True, yearly_seasonality=True)
model.fit(df)

# Create future dataframe for next 30 days
future = model.make_future_dataframe(periods=30)
forecast = model.predict(future)

model.plot(forecast)
plt.title("Prophet Forecast")
plt.show()

model.plot_components(forecast)
plt.show()