Build a demand forecasting system using time series methods to predict future product demand and optimize inventory.
You are a forecasting specialist building a demand prediction system. Based on the following context, create a complete forecasting framework. Product Type: [WHAT YOU ARE FORECASTING - SKU sales, service demand, resource usage] Historical Data Available: [HOW MANY MONTHS OR YEARS OF HISTORY] Forecast Horizon: [HOW FAR AHEAD TO PREDICT - days, weeks, months] Granularity: [DAILY/WEEKLY/MONTHLY AND BY PRODUCT/REGION/STORE] Seasonality: [KNOWN SEASONAL PATTERNS - weekly, monthly, annual, holiday-driven] External Factors: [PROMOTIONS, WEATHER, ECONOMIC INDICATORS, COMPETITOR ACTIONS] Develop the forecasting system across these six sections: 1. DATA PREPARATION AND TIME SERIES ANALYSIS Outline data cleaning steps specific to time series including handling gaps in the series, detecting and treating outliers that may be legitimate demand spikes versus data errors, and adjusting for known events like stockouts that artificially suppress demand. Perform time series decomposition to separate trend, seasonality, and residual components using STL decomposition. Conduct stationarity tests using ADF and KPSS tests with Python code. Create autocorrelation and partial autocorrelation plots to identify the order of autoregressive and moving average components. Provide code using statsmodels for all diagnostics. 2. BASELINE AND STATISTICAL MODELS Implement classical forecasting methods as baselines. Cover naive methods including last value, seasonal naive, and moving average. Build exponential smoothing models using Holt-Winters with both additive and multiplicative seasonality. Implement ARIMA and SARIMA models with automatic order selection using auto_arima from pmdarima. For each model, show how to fit, diagnose residuals with the Ljung-Box test, and generate forecasts with prediction intervals. Compare models using time series cross-validation with rolling or expanding windows rather than simple train-test splits. 3. MACHINE LEARNING FORECASTING APPROACHES Build ML-based forecasting models that can incorporate external regressors. Create a feature matrix with lag features, rolling statistics, calendar features including day of week, month, and holiday indicators, and any external factors. Implement gradient boosting forecasts using LightGBM with proper time-aware cross-validation. Cover Facebook Prophet for its ability to handle holidays and changepoints automatically. If the data has multiple related series, introduce hierarchical forecasting concepts and global models that learn across all series simultaneously. Compare ML approaches against the statistical baselines using consistent evaluation metrics. 4. FORECAST EVALUATION AND MODEL SELECTION Define the evaluation framework using appropriate error metrics. Compute MAE, RMSE, MAPE, and weighted MAPE, explaining when each metric is most appropriate and the pitfalls of each. Implement time series cross-validation with multiple forecast origins to get robust performance estimates. Create visual evaluation tools including forecast versus actual plots, residual analysis, and error distribution by time horizon. Build a model selection framework that considers not just accuracy but also interpretability, computational cost, and maintenance burden. Address the challenge of evaluating probabilistic forecasts using quantile loss and coverage metrics. 5. DEMAND PLANNING AND INVENTORY OPTIMIZATION Connect forecasts to business decisions. Calculate safety stock levels based on forecast uncertainty using the forecast error distribution. Determine reorder points and optimal order quantities using the newsvendor model or similar frameworks. Create scenario analysis showing the cost of over-forecasting versus under-forecasting for the specific business context. Build a demand planning dashboard specification that shows forecasts at different aggregation levels with drill-down capability. Address forecast value added analysis to quantify the business impact of improved forecasting. 6. PRODUCTION DEPLOYMENT AND MONITORING Design the production forecasting pipeline including automated data ingestion, model training, forecast generation, and distribution to downstream systems. Implement forecast monitoring to detect when model performance degrades using control charts on forecast errors. Set up automated alerts for anomalous demand patterns that may indicate data issues or genuine demand shifts. Create a model retraining strategy with criteria for when to retrain versus when to rebuild. Include a process for incorporating human judgment overrides from domain experts while tracking the accuracy impact of manual adjustments.
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[HOW MANY MONTHS OR YEARS OF HISTORY]