Back to Projects
Forecasting
Prophet
HTS
Forecasting for Revenue Planning
Hierarchical time series forecasting with probabilistic evaluation for quarterly planning.
Overview
Developed a sophisticated forecasting system for revenue planning that handles multiple time series hierarchies (product lines, regions, channels). Implemented probabilistic forecasting with Prophet and custom ensemble methods to provide uncertainty quantification for executive decision-making. The system generates forecasts at multiple granularities with automated model selection.
Code Highlight
Hierarchical Time Series Forecasting
import pandas as pdfrom prophet import Prophetimport numpy as npfrom typing import Dict, Listclass HierarchicalForecaster:def __init__(self):self.models = {}self.hierarchy_levels = ['total', 'region', 'product', 'channel']def fit_hierarchical_models(self, data: pd.DataFrame):"""Fit Prophet models at each hierarchy level"""for level in self.hierarchy_levels:level_data = self.aggregate_by_level(data, level)for series_id in level_data['series_id'].unique():series_data = level_data[level_data['series_id'] == series_id]# Configure Prophet with seasonalitymodel = Prophet(yearly_seasonality=True,weekly_seasonality=False,daily_seasonality=False,interval_width=0.95,changepoint_prior_scale=0.05)# Add custom regressorsmodel.add_regressor('marketing_spend')model.add_regressor('economic_index')# Prepare data for Prophetprophet_data = series_data[['ds', 'y', 'marketing_spend', 'economic_index']]model.fit(prophet_data)self.models[f"{level}_{series_id}"] = modeldef generate_forecasts(self, periods: int = 90) -> Dict[str, pd.DataFrame]:"""Generate probabilistic forecasts with reconciliation"""forecasts = {}for model_key, model in self.models.items():future = model.make_future_dataframe(periods=periods)future = self.add_future_regressors(future, model_key)forecast = model.predict(future)forecasts[model_key] = forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']]# Reconcile hierarchical forecastsreturn self.reconcile_forecasts(forecasts)
Key Results
15% improvement in forecast accuracy
Automated monthly planning process
Probabilistic uncertainty bounds
Multi-hierarchy forecasting support
Technologies Used
Python
Prophet
Statsmodels
Pandas
NumPy
Plotly
MLflow
Project Category
data analytics