The user wants a usage-based revenue forecasting model that includes seasonality.
The request is quite broad ("Build a..."). It doesn't specify:
Programming Language: Python is the standard for this. I'll assume Python.
Granularity: Daily, weekly, or monthly? Monthly is usually best for business forecasting.
Data: I don't have the user's data. I need to generate synthetic data that looks like usage-based revenue (e.g., API calls, SaaS subscriptions with overages) with seasonal patterns.
Model Type: ARIMA/SARIMA, Prophet, or Machine Learning (XGBoost/LightGBM)? Prophet is often the best "out-of-the-box" solution for business contexts because it handles seasonality and trend changes well and is easy to interpret. I will focus on a standard approach: Data Generation -> Preprocessing -> Modeling (Prophet is a strong candidate, but a simple linear regression with Fourier features or SARIMA is also educational). Let's go with Prophet for simplicity and robustness with seasonality, but I'll also show a statistical breakdown approach (multiplicative vs. additive) to explain the "usage-based" aspect.
Plan:
Conceptual Framework: Explain the components of a usage-based model (Base + Growth + Seasonality + Noise). Explain why usage-based is different (often multiplicative seasonality).
Data Simulation: Create a dummy dataset representing 2 years of monthly revenue. I'll inject trend, seasonality (peaks in Q4, dips in Q1), and some noise.
Modeling approach:
Option A (The "Easy/Robust" way): Facebook Prophet. It handles seasonality natively.
Option B (The "Math/Stat" way): Decomposition.
Decision: I will provide a complete Python script using Prophet because it's industry standard for this specific request. I will also include a regression-based alternative for those without Prophet, or just explain the logic.
Business Logic Integration: How to interpret the forecast (e.g., "We expect 15% growth MoM but a -5% seasonal dip in Feb").
Refining the "Usage-Based" Aspect:
Usage-based revenue (like Stripe or AWS) behaves differently than subscription revenue.
Subscription: Step functions (churn/add).
Usage: Often smoother but has "multipliers."
Seasonality: E-commerce usage spikes in Q4 (Black Friday). B2B usage dips in Dec/Summer.
Model Choice: Multiplicative seasonality is key here. (Revenue isn't 1000+500 seasonal; it's $1000 * 1.5 seasonal). Prophet handles this well.
Drafting the Content:
Introduction: Define the inputs.
Step 1: Synthetic Data: Create a dataset where Revenue=Base×(1+Trend.
Let's write the code in Python.
Self-Correction during thought process:
Just giving code might be overwhelming. I should structure it as a guide.
The Math: Explain the multiplicative formula.
The Python Implementation: Use prophet (library). It's the most practical tool.
The Interpretation: How to use the output.
Code Snippet Plan:
python
import pandas as pd
from prophet import Prophet
# Generate data
# Fit model
m = Prophet(seasonality_mode='multiplicative') # Crucial for usage-based
# Predict
Let's add a "Scenario Planning" section at the end. Usage-based models often need to account for pricing changes or new customer cohorts. I'll keep it simple for now but mention it.
Let's write it out.
This guide breaks down how to build a robust usage-based revenue forecasting model. Unlike subscription (SaaS) revenue, which is relatively flat, usage-based revenue (like API calls, data storage, or transaction fees) requires a Multiplicative Model.
In a usage model, seasonality usually scales with the size of the business (e.g., if you double your customers, your holiday traffic spike likely doubles too).
The Mathematical Logic
We will use a multiplicative decomposition model:
Revenue=(Trend×Seasonalit
Trend: The underlying growth trajectory of your user base.
Seasonality: Repeating patterns (e.g., drops on weekends, spikes in Q4).
Growth Factor: A variable to simulate usage-per-customer expansion (upsell).
Python Implementation
We will use Python with pandas for data manipulation and prophet (by Meta) for the forecasting engine. Prophet is ideal for this because it handles multiplicative seasonality natively and is robust to outliers.
Prerequisites
You will need to install prophet:
bash
pip install pandas prophet matplotlib
The Code
Here is a complete, runnable script. It includes a synthetic data generator so you can see the model in action immediately.
python
import pandas as pd
import numpy as np
from prophet import Prophet
import matplotlib.pyplot as plt
# ==========================================
# 1. GENERATE SYNTHETIC USAGE DATA
# ==========================================
# In a real scenario, load your CSV: df = pd.read_csv('revenue.csv')
def generate_usage_data():
# 2 years of daily data
dates = pd.date_range(start='2022-01-01', end='2023-12-31', freq='D')
# Base components
trend = np.linspace(1000, 5000, len(dates)) # Linear growth from 1k to 5k
# Seasonality (Yearly: High in Dec, Low in Jan) + (Weekly: Low on weekends)
yearly_seasonality = 1000 * np.sin(2 * np.pi * (dates.dayofyear / 365.25))
weekly_seasonality = np.where(dates.dayofweek >= 5, -500, 0) # Drop on weekends
# Random noise
noise = np.random.normal(0, 150, len(dates))
# Combine (Multiplicative effect: Seasonality scales with trend)
# As trend grows, the amplitude of seasonality grows
revenue = trend + (yearly_seasonality * (trend/2000)) + weekly_seasonality + noise
df = pd.DataFrame({'ds': dates, 'y': revenue})
return df
df = generate_usage_data()
# ==========================================
# 2. PRE-PROCESSING
# ==========================================
# Prophet requires columns to be named 'ds' (date) and 'y' (value)
print(df.head())
# ==========================================
# 3. DEFINE AND CONFIGURE THE MODEL
# ==========================================
# Key for Usage-Based models: Set seasonality_mode to 'multiplicative'
model = Prophet(
seasonality_mode='multiplicative',
yearly_seasonality=True,
weekly_seasonality=True,
daily_seasonality=False
)
# OPTIONAL: Add 'Regressors' (External Factors)
# If you know marketing spend or number of active users for future dates, add them here.
# model.add_regressor('marketing_spend')
# ==========================================
# 4. FIT AND PREDICT
# ==========================================
model.fit(df)
# Create a future dataframe (predict next 90 days)
future_dates = model.make_future_dataframe(periods=90)
# Generate the forecast
forecast = model.predict(future_dates)
# ==========================================
# 5. VISUALIZATION
# ==========================================
fig1 = model.plot(forecast)
plt.title('Usage-Based Revenue Forecast (Multiplicative)')
plt.xlabel('Date')
plt.ylabel('Revenue')
plt.show()
# Plot components (Trend vs Seasonality)
fig2 = model.plot_components(forecast)
plt.show()
# ==========================================
# 6. EXPORT RESULTS
# ==========================================
# Save specific columns for business planning
output = forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']]
output.to_csv('revenue_forecast.csv', index=False)
print("Forecast saved to CSV.")
This is the most important setting for usage-based models.
Additive: Assumes the holiday spike is always $10k, regardless of company size.
Multiplicative: Assumes the holiday spike is always 20% of your revenue. As you grow, the dollar value of that spike grows. The code above uses this setting.
2. The Regressors (External Variables)
Usage-based revenue is often driven by customer count. If you acquire 100 new enterprise clients next month, your revenue will jump, regardless of seasonality.
If you have data on Active Users or Marketing Spend, you should add it to the dataframe before fitting:
python
# Example of adding an external regressor
df['active_users'] = ... # Load this data
model.add_regressor('active_users')
Note: To forecast the future with a regressor, you must provide future values for active_users in the future_dates dataframe.
3. The "Floor" (Logistic Growth)
Usage-based revenue can sometimes hit zero (floor). If you are forecasting a new product with hyper-growth that might flatten out, use Logistic Growth to set a "cap" (maximum potential market) and a "floor" (minimum revenue).
python
df['cap'] = 10000 # Max market capacity
df['floor'] = 0 # Revenue cannot be negative
model = Prophet(growth='logistic')
How to Interpret the Output
When you run model.plot_components(forecast), you will see three graphs:
Trend: The baseline growth. Is it linear or accelerating?
Weekly: Reveals usage patterns. (e.g., "Revenue drops 30% on Saturdays").
Yearly: Reveals macro seasonality. (e.g., "Q4 is consistently 40% higher than Q1").
Advanced: Handling Pricing Tiers
If your usage model charges different rates (e.g., $0.10 per unit for the first 1,000, then $0.08), do not forecast revenue directly.
Forecast Usage Volume (Total API Calls / GB Stored).
Apply your pricing logic to the forecasted volume in a spreadsheet or separate function. This separates "usage behavior" from "pricing logic," making the model more accurate.
)t
×
Seasonality×
Noise
Step 2: The Model (Prophet): Why? It separates trend from seasonality automatically.