Predict demand for your services
The problem
You need to plan staffing, stock, or capacity but you don't know how many people will need your service next month. You've got historical data but it sits in spreadsheets. You end up either overstaffed or scrambling to meet unexpected demand.
The solution
Use time series forecasting to predict future demand based on your historical patterns. The model learns from your past data: seasonal patterns (more food bank visits before Christmas, fewer advice sessions in August), trends (growing or shrinking over time), and regular fluctuations. Then it projects forward with confidence intervals.
What you get
A forecast for the next weeks or months showing expected demand with upper and lower bounds. You can see where demand is likely to spike and plan accordingly. The model also shows you the patterns it's learned, so you can sanity check whether they make sense.
Before you start
- At least 1-2 years of historical demand data (more is better for seasonal patterns)
- Data with dates and counts - daily or weekly works best; monthly can work but needs 3+ years to detect patterns
- A Google account for Colab
- Basic comfort with Python or willingness to adapt example code
- IMPORTANT: Service usage data may be sensitive. Anonymise or aggregate data before uploading to Google Colab - use counts only, not individual records. Check your GDPR compliance covers this use of service data
When to use this
- You need to plan staff rotas, stock levels, or volunteer schedules in advance
- Your demand has predictable patterns (seasonal, weekly, etc.) that could be learned
- You've got at least a year of historical data to train the model
- Being wrong about demand has real consequences (understaffing, waste, unmet need)
When not to use this
- Your demand is genuinely random with no patterns
- You've only got a few months of data, not enough to learn patterns
- External factors (like a pandemic) have changed everything and old patterns don't apply
- You don't have capacity to act on forecasts anyway
Steps
- 1
Gather your historical data
Export your demand data with dates: how many people used the service each day, week, or month. Daily or weekly data works best. Monthly data can work but you'll need 3+ years to detect seasonal patterns reliably. You need at least 12 months to capture seasonality, ideally 2+ years. The data should be regular (no missing periods) and accurate.
- 2
Clean and prepare the data
Check for gaps, outliers, and errors. If there's a period where you didn't record data, fill it in or note it. Extreme outliers (a day when data wasn't recorded properly) should be removed or they'll confuse the model. The example code shows how to handle this.
- 3
Visualise the historical patterns
Plot your data to see what patterns exist. Is there a weekly cycle? Seasonal peaks and troughs? An overall trend up or down? Understanding these helps you check whether the model's learned something sensible.
- 4
Train the forecasting model
Use Prophet or a similar library to train on your historical data. Prophet automatically detects weekly, yearly, and other patterns. It's designed to be robust without much tuning, so the default settings often work well.
- 5
Generate forecasts
Ask the model to predict the next 4-12 weeks (or whatever horizon you need). It will give you a point forecast plus upper and lower bounds (uncertainty intervals). The further out you forecast, the wider the uncertainty.
- 6
Validate and adjust
Check whether the forecasts make sense. Does the model capture the patterns you know exist? You can add known future events (school holidays, local events) as variables to improve accuracy - Prophet has a built-in UK holidays feature: `model.add_country_holidays(country_name='UK')`. Test by forecasting a period you already have data for and comparing.
- 7
Build into your planning process(optional)
Run forecasts regularly as part of your planning cycle. Compare actual vs predicted to track accuracy and improve over time. Share forecasts with staff so they know what's coming.
Example code
Forecast demand with Prophet
This trains a forecasting model on your historical data and predicts the next 12 weeks. Prophet handles seasonality automatically. The 'y' column is your demand measure - this could be food parcels distributed, helpline calls received, advice sessions delivered, or any countable service metric.
# Install Prophet first: !pip install prophet
import pandas as pd
from prophet import Prophet
import matplotlib.pyplot as plt
# Load your data
# Needs columns: 'ds' (date) and 'y' (demand count)
df = pd.read_csv('demand_history.csv')
df['ds'] = pd.to_datetime(df['date'])
df['y'] = df['visits'] # or whatever your demand column is called
df = df[['ds', 'y']]
# Remove any obvious outliers (optional)
# df = df[df['y'] < df['y'].quantile(0.99)]
# Visualise the historical data
plt.figure(figsize=(12, 4))
plt.plot(df['ds'], df['y'])
plt.title('Historical demand')
plt.xlabel('Date')
plt.ylabel('Demand')
plt.show()
# Train the model
model = Prophet(
yearly_seasonality=True, # Capture annual patterns
weekly_seasonality=True, # Capture day-of-week patterns
daily_seasonality=False # Usually not needed for daily/weekly data
)
model.fit(df)
# Create future dates to predict
future = model.make_future_dataframe(periods=84) # 12 weeks
# Generate forecast
forecast = model.predict(future)
# Plot the forecast
fig = model.plot(forecast)
plt.title('Demand forecast with uncertainty')
plt.show()
# Show the seasonal patterns the model learned
fig2 = model.plot_components(forecast)
plt.show()
# Export forecast for the future period
future_forecast = forecast[forecast['ds'] > df['ds'].max()][['ds', 'yhat', 'yhat_lower', 'yhat_upper']]
future_forecast.columns = ['date', 'predicted', 'lower_bound', 'upper_bound']
future_forecast.to_csv('demand_forecast.csv', index=False)
print("\nForecast for next 4 weeks:")
print(future_forecast.head(28).to_string(index=False))Tools
Resources
At a glance
- Time to implement
- days
- Setup cost
- free
- Ongoing cost
- free
- Cost trend
- stable
- Organisation size
- small, medium, large
- Target audience
- operations-manager, data-analyst, ceo-trustees
All tools are free. Once set up, generating new forecasts takes minutes.