Intelligent Demand Forecasting System
An ensemble forecasting engine with 15+ algorithms that automatically selects the best model based on demand pattern classification using ADI/CV² analysis.
The Challenge
Supply chain forecasting is notoriously difficult because not all products behave the same way. A best-seller with consistent daily sales needs a different forecasting approach than a slow-moving spare part ordered once a month.
The existing system used a one-size-fits-all approach—applying the same simple moving average to all 10,000+ SKUs. This led to:
- Frequent stockouts on fast-moving items (losing sales)
- Excess inventory on slow-movers (tying up capital)
- Manual overrides by planners consuming hours daily
- No visibility into why forecasts were off
The Solution
I built an intelligent forecasting system that classifies each SKU's demand pattern and automatically selects the most appropriate algorithm from an ensemble of 15+ models.
Pattern Classification (ADI/CV²)
The system uses two key metrics to classify demand patterns:
- ADI (Average Demand Interval) — How often does demand occur?
- CV² (Coefficient of Variation Squared) — How variable is demand size?
Regular, predictable demand. Best for time series models.
Frequent but variable demand. Needs robust methods.
Infrequent but consistent quantities when ordered.
Rare and unpredictable. Hardest to forecast.
Algorithm Ensemble
The system includes 15+ forecasting algorithms, each optimized for different demand characteristics:
ARIMA
Auto-regressive integrated moving average for stationary series
Time SeriesProphet
Facebook's model for seasonality and holiday effects
SeasonalityHolt-Winters
Triple exponential smoothing for trends
TrendingXGBoost
Gradient boosting with feature engineering
MLRandom Forest
Ensemble of decision trees for robustness
MLCroston
Specialized for intermittent demand
IntermittentSBA
Syntetos-Boylan Approximation
IntermittentTSB
Teunter-Syntetos-Babai for lumpy demand
LumpySimple Exponential
Baseline model for stable demand
Baseline+ Moving Averages, Linear Regression, LSTM, Theta Method, Naive Methods, and more...
Implementation
The pattern classifier uses a clean, configurable design:
class DemandPatternClassifier: """Classify SKU demand patterns using ADI/CV² analysis.""" def __init__(self, adi_threshold=1.32, cv2_threshold=0.49): self.adi_threshold = adi_threshold self.cv2_threshold = cv2_threshold def classify(self, demand_series: pd.Series) -> DemandPattern: # Calculate Average Demand Interval non_zero_periods = (demand_series > 0).sum() adi = len(demand_series) / non_zero_periods if non_zero_periods > 0 else float('inf') # Calculate CV² (squared coefficient of variation) non_zero_demand = demand_series[demand_series > 0] cv2 = (non_zero_demand.std() / non_zero_demand.mean()) ** 2 # Classify based on thresholds if adi < self.adi_threshold and cv2 < self.cv2_threshold: return DemandPattern.SMOOTH elif adi < self.adi_threshold and cv2 >= self.cv2_threshold: return DemandPattern.ERRATIC elif adi >= self.adi_threshold and cv2 < self.cv2_threshold: return DemandPattern.INTERMITTENT else: return DemandPattern.LUMPY
Tech Stack
Key Learnings
No Silver Bullet
Different demand patterns need different algorithms. The classifier approach improved accuracy by 25% over one-size-fits-all.
Intermittent is Hard
40% of SKUs had intermittent/lumpy demand. Croston and TSB significantly outperformed traditional methods here.
Feature Engineering Matters
Adding promotional calendars, seasonality flags, and lead time features boosted ML model accuracy by 15%.
Explainability Wins Trust
Showing planners WHY a forecast was generated (pattern type, algorithm used) increased adoption significantly.
Interested in the Details?
Let's discuss how intelligent forecasting can transform your supply chain operations.