Prophet#

“Because not everyone has time to debug ARIMA on a Monday morning.”


🧙‍♂️ What Is Prophet?#

Prophet (by Facebook/Meta) is your friendly time-series forecasting assistant. It’s designed for business analysts, product managers, and data scientists who want solid forecasts without sacrificing their weekend.

Think of it as:

“ARIMA, but with an MBA and a calendar.” 📅


⚡ Why Prophet Rocks#

  • Handles trends, seasonality, holidays, and outliers automatically

  • Plays nicely with messy business data (sales, traffic, signups, etc.)

  • Gives interpretable components — so you can explain results to your boss

  • And the syntax? Chef’s kiss. 👨‍🍳


🧩 Basic Prophet Workflow#

Let’s forecast some sales data like it’s magic:

from prophet import Prophet
import pandas as pd

# Data must have columns 'ds' (date) and 'y' (value)
df = pd.DataFrame({
    'ds': pd.date_range(start='2021-01-01', periods=36, freq='M'),
    'y': [100 + i*3 + (10 * (i % 6)) for i in range(36)]
})

model = Prophet()
model.fit(df)

future = model.make_future_dataframe(periods=12, freq='M')
forecast = model.predict(future)

That’s it! 🎉 Prophet just did:

  • Trend modeling

  • Seasonality fitting

  • Forecasting

  • All while you were reheating coffee


📈 Plotting Like a Prophet#

from prophet.plot import plot_plotly, plot_components_plotly

plot_plotly(model, forecast)
plot_components_plotly(model, forecast)

💡 Interpretation:

  • Trend → Long-term growth/decline

  • Yearly seasonality → Regular business cycles (e.g., Black Friday)

  • Weekly seasonality → Behavior changes over weekdays/weekends

  • Holidays → Extra spikes (or slumps) due to marketing campaigns, etc.


🎉 Adding Holidays (Because Business Loves Them)#

from prophet.make_holidays import make_holidays_df

holidays = pd.DataFrame({
    'holiday': 'promo_days',
    'ds': pd.to_datetime(['2023-11-24', '2023-12-25', '2024-01-01']),
    'lower_window': 0,
    'upper_window': 1,
})

model = Prophet(holidays=holidays)
model.fit(df)

🗓️ Prophet automatically adds spikes for those special days — no need to handcraft a “Holiday Hype Index” anymore.


🤔 Interpreting Components#

Component

Meaning

Analogy

Trend

Long-term movement

“Our business is growing… hopefully.”

Seasonality

Repeated cycles

“Every December we sell more sweaters.”

Holiday effects

Short-term anomalies

“Marketing sent another discount email.”

Prophet keeps things interpretable, so you can sound smart and confident in meetings.


⚙️ Tuning Prophet#

You can customize Prophet’s behavior with a few simple knobs:

model = Prophet(
    changepoint_prior_scale=0.1,  # Flexibility of trend changes
    seasonality_mode='multiplicative',  # or 'additive'
    seasonality_prior_scale=15.0  # How wiggly seasonality can be
)

🪄 Rule of thumb:

  • If Prophet overfits → lower the prior scales

  • If it underfits → increase them a bit

(Just like making instant noodles — don’t overcook it.)


💼 Business Case Example#

Let’s say your company sells coffee beans. ☕ You’ve got:

  • Steady monthly growth (trend)

  • Sales peaks every December (seasonality)

  • Crazy spikes on promo days (holidays)

Prophet nails all three — and gives you a forecast with reasons you can actually explain to finance and marketing.

CFO: “Why did sales dip in June?”

You: “Because coffee is seasonal, and people were busy buying iced lattes instead.” 😎


🧾 TL;DR#

Feature

Prophet Superpower

Data format

Simple: ds and y

Handles seasonality

Automatically

Handles holidays

Yes (customizable)

Explainability

Excellent

Effort level

Coffee break

Business love

❤️❤️❤️


🧠 Quick Recap Quiz#

Try to guess before scrolling:

  1. Prophet models trend + seasonality + holiday (True/False?)

  2. It needs columns named ds and y (True/False?)

  3. You can’t add custom holidays (True/False?)

Answers: ✅ True, ✅ True, ❌ False — you can add holidays!


“Prophet: where your forecasts make sense, your plots look great, and you can finally sleep during Q4 planning season.” 💤

# Your code here