ForecastFactory is an advanced AI-powered forecasting and simulation platform built with Python, Streamlit, Prophet, and SQLAlchemy. It enables analysts, data scientists, and business strategists to simulate business outcomes under different βwhat-ifβ scenarios, allowing organizations not just to predict, but to plan and adapt intelligently.
ForecastFactory bridges the gap between data-driven forecasting and strategic scenario planning. Traditional forecasting tools answer βwhat will happen,β while ForecastFactory explores βwhat could happenβ under changing conditions like pricing shifts, ad budget changes, or supply constraints.
Core Purpose: Empower teams to simulate future outcomes, test assumptions, and quantify the effect of strategic decisions in real time.
Most organizations rely on static forecasts that canβt adapt to real-world changes. ForecastFactory empowers them to:
- Quantify trade-offs: What if ad spend rises by 20%?
- Stress-test assumptions: How sensitive is revenue to a price increase?
- Prepare for volatility: What if demand drops due to supply shortages?
It transforms forecasting from passive prediction into active decision simulation.
- AI Forecasting: Prophet-based trend, holiday, and seasonality modeling.
- Scenario Engine: Interactive βwhat-ifβ analysis with domain-driven adjustments.
- Elasticity Modeling: Realistic impact simulation via custom elasticity coefficients.
- SQL-Integrated Pipeline: Seamlessly fetch data via SQLAlchemy.
- Dynamic Visualization: Real-time Plotly and Streamlit dashboards.
- Explainability: Automated narrative summaries for business interpretation.
- Exportable Outputs: Save data as CSV or Markdown reports.
flowchart LR
A["SQL / CSV Data Source"] --> B["ETL + Feature Engineering"]
B --> C["Forecast Model (Prophet + Baseline)"]
C --> D["Scenario Engine (Elasticity Adjustments)"]
D --> E["Explainability Layer (Attribution + Narrative)"]
E --> F["Visualization (Streamlit + Plotly)"]
F --> G["Exports: CSV / Model / Insights"]
The system is modular and extensible, enabling analysts to plug in new models or connect it to MLOps pipelines for continuous retraining.
- SQLite used for quick prototyping, extensible to PostgreSQL or Snowflake.
- SQLAlchemy ORM provides seamless connection and schema management.
- Data cleaned and aggregated via Pandas ETL transformations.
- Powered by Prophet, modeling seasonality, trend, and holiday effects.
- Fallback to Moving Average for baseline comparison.
- Backtesting pipeline validates performance via MAE, RMSE, and SMAPE.
-
Defines relationships such as:
ΞQ/Q = Ξ΅ Γ ΞP/P(Price elasticity)Uplift = Ξ± Γ log(1 + Ξ² Γ AdSpend)(Media response)Q' = Q Γ (1 + Ξ³ Γ PromoFlag)(Promotion effects)
-
Produces differential forecasts showing net impact vs baseline.
- Streamlit powers the interactive UI.
- Plotly renders visual insights with interactivity and real-time updates.
- Exports available in CSV format for further analysis.
- Integrates Prophet component decomposition and SHAP-like narratives.
- Generates business-oriented insights: βIncreased ad spend drove +7.8% uplift over baseline between July-August.β
Define the data source, KPI, and forecast horizon.
Displays Prophet-based forecasts with confidence intervals.
Interactively tweak ad spend, pricing, or promotions to simulate impact.
Visualize baseline vs simulated outcomes, with quantified uplift metrics.
Objective: Forecast 90 days of revenue while simulating increased ad spend and promotions.
-
Baseline: Prophet trained on 2 years of revenue data.
-
Scenario: +15% ad spend, 10% promotion activation.
-
Elasticity Equations:
- Ad response = 0.3 Γ log(1 + 0.001 Γ spend)
- Promo uplift = +6%
-
Result: +8.7% projected uplift vs baseline; Β±2.3% confidence margin.
-
Insight: The simulator suggested that moderate ad increases yield diminishing returns after 15% budget growth.
forecastfactory/
β
βββ app.py # Streamlit main interface
βββ db/
β βββ schema.sql # Database schema
β βββ seed.sql # Sample data
βββ forecastfactory
β βββ __init__.py
β βββ elasticity.py
β βββ explain.py
β βββ features.py
β βββ io_sql.py
β βββ models.py
β βββ scenario.py
β βββ viz.py
βββ config.yaml # Configuration
βββ requirements.txt # Dependencies
| Metric | Formula | Description |
|---|---|---|
| MAE | Ξ£ | yβΕ· |
| RMSE | βΞ£(yβΕ·)Β² / n | Penalizes larger errors |
| SMAPE | (200/n) Ξ£ | yβΕ· |
- Price Elasticity: ΞQ/Q = Ξ΅ Γ ΞP/P
- Media Response: Uplift = Ξ± Γ log(1 + Ξ² Γ AdSpend)
- Promo Effect: Qβ = Q Γ (1 + Ξ³ Γ PromoFlag)
| Table | Description |
|---|---|
fact_kpi_daily |
KPI value by day |
fact_drivers_daily |
Drivers (price, ad spend, promo) |
dim_calendar |
Holidays and day-of-week metadata |
git clone https://github.com/AmirhosseinHonardoust/Forecast-Factory.git
cd ForecastFactory
pip install -r requirements.txt
streamlit run app.pyIf Prophet is missing:
pip install prophet pystan==2.19.1.1Database initialization:
python -m forecastfactory.cli init| Sector | Example Use Case |
|---|---|
| E-commerce | Predict sales under different promo policies |
| Marketing | Simulate ROI of ad budget increases |
| Finance | Stress-test revenue against macroeconomic shocks |
| Retail | Optimize stock levels under demand uncertainty |
| Operations | Forecast capacity or workforce requirements |
- Integrate XGBoost and LSTM for hybrid forecasting.
- Introduce AutoML model selection and backtesting reports.
- Add multi-scenario comparison (budget vs promo vs combined).
- Implement role-based dashboards with Streamlit authentication.
- Export results to Power BI or Google Data Studio.
- Connect to real-time APIs for adaptive forecasting.
- Prophet Documentation
- XGBoost Docs
- Streamlit API Reference
- Plotly Python Library
- SQLAlchemy ORM
- SHAP Framework
Forecast-Factory transforms forecasting into a dynamic, interactive experience that merges machine learning, simulation, and human insight. Itβs a platform where analysts donβt just observe the future, they shape it through data-driven experimentation.