Skip to content

End-to-end demand prediction AI with Python using synthetic time-series sales data

Notifications You must be signed in to change notification settings

bravonokoth/demand_prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Demand Prediction AI (Time-Series) 🛒📈

End-to-End AI Demand Prediction System | 2.77% Accuracy | SARIMA Model | Production-Ready

Demo

Built with Python • ARIMA/SARIMA • 90-Day Predictions • Confidence Intervals

Python License Stars


What It Does

  • Generates realistic daily sales data (trend + seasonality + noise)
  • AI Model Search: Finds best SARIMA model using AIC
  • Predicts 90-day future demand with 95% confidence intervals
  • Validates accuracy: RMSE 2.11 | MAPE 2.77%
  • Visualizes predictions + residual diagnostics

📊 Live Results

Metric Value Status
Prediction Accuracy 2.77% MAPE ✅ Excellent
RMSE 2.11 ✅ Excellent
AI Model SARIMA(2,1,2)x(0,1,1,7) ✅ Optimal
AIC Score 2836.7 ✅ Best Fit
Prediction Horizon 90 Days ✅ Production

Results


🚀 Run in 60 Seconds

# 1. Clone
git clone https://github.com/bravon/demand_prediction.git
cd demand_prediction

# 2. Setup (Ubuntu)
sudo apt install python3-distutils -y
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# 3. Generate Data
python3 data/generate_timeseries.py --seed 42

# 4. Predict Demand
python3 src/predict_demand.py --horizon 90

# 5. View Results
ls outputs/

Outputs Generated:

📊 metrics.json          # 2.77% MAPE
📈 prediction.csv        # 90-day forecast
📊 fig_history_prediction.png  # Main chart
🔍 fig_residuals.png     # Diagnostics

📁 Project Structure

demand-prediction/
├── README.md            # 📖 You're reading it!
├── requirements.txt     # 📦 pip install
├── data/
│   └── generate_timeseries.py  # 🧪 Synthetic data
├── src/
│   ├── predict_demand.py       # 🤖 MAIN AI SCRIPT
│   └── metrics.py      # 📏 RMSE/MAPE
└── outputs/             # 📈 Results (gitignored)

🛠 Data Schema

Column Type Description
date Date Daily timestamp
sales int Units sold
prediction float AI Forecast
lower_ci float 95% Lower bound
upper_ci float 95% Upper bound

🔧 Tech Stack

Category Tools
Language Python 3.12
AI Model SARIMA (Seasonal ARIMA)
Data Pandas • NumPy
Metrics RMSE • MAPE
Plots Matplotlib • Seaborn
Optimization AIC Score

📈 Sample Prediction Output

date,prediction,lower_ci,upper_ci
2025-01-01,245.3,232.1,258.5
2025-01-02,247.8,234.2,261.4
...

🤝 Contributing

  1. Fork the repo
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m '💥 Add amazing feature')
  4. Push (git push origin feature/amazing)
  5. Open Pull Request

📄 License

MIT License - Free to use in portfolios/commercial!


---

About

End-to-end demand prediction AI with Python using synthetic time-series sales data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages