0Pricing
Learn AI with Python · Lesson

Prophet for Automated Forecasting

Facebook Prophet, trend changepoints, holiday effects, uncertainty intervals, cross-validation.

Prophet for Automated Forecasting is a free Learn AI with Python lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Learn AI with Python learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is Prophet?

Prophet is an open-source forecasting library from Meta. It fits trend, seasonality, and holiday effects automatically, handles missing data and outliers gracefully, and needs far less tuning than ARIMA, making it great for business forecasts.

Installing and Importing

Prophet is a single import once installed.

# pip install prophet
from prophet import Prophet
import pandas as pd

Required DataFrame Format

Prophet requires exactly two columns: ds (datestamp) and y (the value to forecast). Renaming your columns to these names is mandatory.

df = df.rename(columns={"date": "ds", "sales": "y"})
df["ds"] = pd.to_datetime(df["ds"])
print(df.head())

Creating the Model

Instantiate Prophet, optionally choosing how seasonality combines with the trend. multiplicative suits series where seasonal swings grow with the level.

m = Prophet(seasonality_mode="multiplicative")

Additive vs Multiplicative Seasonality

Default is additive (constant seasonal amplitude). Use multiplicative when peaks get bigger as the trend rises, like sales that swing more during high-volume years.

Fitting the Model

Call fit on the prepared DataFrame. Prophet estimates trend changepoints and seasonal components automatically.

m.fit(df)

Building a Future DataFrame

make_future_dataframe extends the date index forward so Prophet knows which dates to predict.

future = m.make_future_dataframe(periods=90, freq="D")
print(future.tail())

Generating Predictions

predict returns a DataFrame with yhat (forecast) plus yhat_lower and yhat_upper uncertainty bounds.

forecast = m.predict(future)
forecast[["ds", "yhat", "yhat_lower", "yhat_upper"]].tail()

Plotting the Forecast

Prophet has built-in plots: the forecast with uncertainty, and a components plot breaking out trend and each seasonality.

fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)

Adding Holidays and Regressors

You can register country holidays or custom events, and add extra explanatory variables with add_regressor, which often boosts accuracy for business data.

m.add_country_holidays(country_name="US")
m.add_regressor("promo_flag")

Cross-Validation

Prophet validates with rolling-origin cross_validation, then performance_metrics reports RMSE, MAE, and MAPE across horizons.

from prophet.diagnostics import cross_validation, performance_metrics

cv = cross_validation(m, initial="365 days",
                      period="90 days", horizon="90 days")
performance_metrics(cv).head()

Quick Check

Test your Prophet knowledge.

Recap

You used Prophet: rename columns to ds and y, create Prophet(seasonality_mode="multiplicative"), fit, build a future frame with make_future_dataframe, predict, plot, and validate with cross_validation. Next: LSTM forecasting.

Frequently asked questions

Is the “Prophet for Automated Forecasting” lesson free?

Yes — the full text of “Prophet for Automated Forecasting” is free to read here on the web, and the Learn AI with Python course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Learn AI with Python course, upgrade to CoddyKit PRO.

What will I learn in “Prophet for Automated Forecasting”?

Facebook Prophet, trend changepoints, holiday effects, uncertainty intervals, cross-validation. You practise Learn AI with Python with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Learn AI with Python?

No prior experience is required. Learn AI with Python on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Prophet for Automated Forecasting” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Learn AI with Python lesson?

Yes. Every Learn AI with Python lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Time Series Components and Stationarity
  2. ARIMA and SARIMA Models
  3. Prophet for Automated Forecasting
  4. LSTM for Time Series Forecasting
← Back to Learn AI with Python