CoolFace
Apppublic

rshewatkar/shipment-delay-predictor

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐Ÿšš Shipment Delay Predictor โ€” Logistics ML System

Python Streamlit Scikit-Learn XGBoost Status HuggingFace


๐Ÿš€ Live Demo

๐Ÿ‘‰ [Click Here to Try the App](https://rshewatkar-shipment-delay-predictor.hf.space)

Deployed on Hugging Face Spaces with CI/CD (GitHub Actions)

๐Ÿ“Œ Project Overview

An end-to-end Machine Learning system that predicts shipment delay risk before dispatch.

Built for logistics and courier companies to:

  • โ€”Reduce late deliveries
  • โ€”Improve customer satisfaction
  • โ€”Enable proactive decision-making
โš ๏ธ Key Insight: ~60% of shipments are delayed โ€” this model flags high-risk orders early.

๐Ÿ  Dashboard Overview

[image]

๐Ÿ”ฎ Prediction Flow

[image]

โš ๏ธ Risk Analysis

[image]


๐ŸŽฏ Problem Statement

Late deliveries lead to:

  • โ€”Refunds & penalties
  • โ€”Customer dissatisfaction
  • โ€”Operational inefficiencies

This system predicts delay probability at booking time โ€” enabling early intervention.


๐Ÿ“Š Dataset Overview

PropertyDetails
SourceKaggle (E-Commerce Shipping Dataset)
Records10,999
Features12
TargetReached.on.Time_Y.N
Delay Rate59.7%

๐Ÿ” Key Insights (EDA)

  • โ€”๐ŸŽฏ Discount > 10% โ†’ High delay probability
  • โ€”โš–๏ธ 2โ€“4 kg weight โ†’ Highest delay rate
  • โ€”๐Ÿšข Ship mode โ†’ Most delays
  • โ€”๐Ÿ“ž Customer calls โ‰ฅ 4 โ†’ Strong delay signal

โš™๏ธ Feature Engineering

FeatureDescription
high_discountFlag for discount > 10%
weight_bucketCategorized weight ranges
high_call_riskCalls โ‰ฅ 4

๐Ÿค– Model Performance

ModelAccuracyPrecisionRecallF1AUC
Decision Tree64.18%69.57%71.06%70.31%62.53%
Random Forest66.32%77.82%60.93%68.35%73.49%
XGBoost โœ…67.00%73.77%69.38%71.51%75.29%

๐Ÿ’ก Business Impact

  • โ€”๐Ÿ“ˆ 69% of delayed shipments correctly identified
  • โ€”๐ŸŽฏ 73% precision in delay prediction
  • โ€”๐Ÿ“‰ Potential 15โ€“25% reduction in late deliveries

๐Ÿ–ฅ๏ธ App Features

FeatureDescription
๐Ÿ“ฅ Input FormEnter shipment details
๐Ÿ“Š PredictionDelay probability output
โš ๏ธ Risk AnalysisKey contributing factors
๐Ÿ“ข RecommendationsActionable insights

๐Ÿ“ Project Structure

bash
shipment-delay-predictor/
โ”‚
โ”œโ”€โ”€ app.py                          # Streamlit app (entry point)
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ sync-to-hub.yml         # CI/CD pipeline (GitHub โ†’ Hugging Face)
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ raw/
โ”‚   โ””โ”€โ”€ processed/
โ”‚
โ”œโ”€โ”€ notebooks/
โ”‚   โ”œโ”€โ”€ EDA.ipynb
โ”‚   โ”œโ”€โ”€ preprocessing.ipynb
โ”‚   โ””โ”€โ”€ modeling.ipynb
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ preprocess.py
โ”‚   โ”œโ”€โ”€ train.py
โ”‚   โ”œโ”€โ”€ predict.py
โ”‚   โ””โ”€โ”€ utils.py
โ”‚
โ”œโ”€โ”€ models/                        # Trained ML models
โ”‚   โ”œโ”€โ”€ best_model.pkl
โ”‚   โ”œโ”€โ”€ scaler.pkl
โ”‚   โ””โ”€โ”€ label_encoders.pkl
โ”‚
โ”œโ”€โ”€ reports/                       
โ”‚   โ”œโ”€โ”€ figures/
โ”‚   โ”‚   โ”œโ”€โ”€01_target_distribution.png
โ”‚   โ”‚   โ”œโ”€โ”€02_delay_by_warehouse.png
โ”‚   โ”‚   โ”œโ”€โ”€03_delay_by_mode.png
โ”‚   โ”‚   โ”œโ”€โ”€04_discount_effect.png
โ”‚   โ”‚   โ”œโ”€โ”€05_weight_effect.png
โ”‚   โ”‚   โ”œโ”€โ”€06_customer_calls.png
โ”‚   โ”‚   โ”œโ”€โ”€07_correlation_heatmap.png
โ”‚   โ”‚   โ”œโ”€โ”€08_model_comparison.png
โ”‚   โ”‚   โ”œโ”€โ”€09_confusion_matrix.png
โ”‚   โ”‚   โ”œโ”€โ”€10_roc_curve.png
โ”‚   โ”‚   โ””โ”€โ”€11_feature_importance.png
โ”‚   โ”‚ 
โ”‚   โ””โ”€โ”€ screenshots/
โ”‚        โ”œโ”€โ”€dashboard-main.png
โ”‚        โ”œโ”€โ”€dashboard-result.png
โ”‚        โ””โ”€โ”€dashboard-risk.png

โš™๏ธ How to Run Locally

1. Clone the repository

bash
git clone https://github.com/rshewatkar/shipment-delay-predictor.git
cd shipment-delay-predictor

2. Install dependencies

bash
pip install -r requirements.txt

3. Run the app

bash
streamlit run app.py

๐Ÿ” ML Pipeline

  1. 1.Data Collection
  2. 2.Data Preprocessing
  3. 3.Feature Engineering
  4. 4.Model Training (XGBoost)
  5. 5.Model Evaluation
  6. 6.Deployment (Streamlit + Hugging Face)

๐Ÿ› ๏ธ Tech Stack

CategoryTools
LanguagePython
MLScikit-learn, XGBoost
DataPandas, NumPy
VisualizationMatplotlib, Seaborn
AppStreamlit
DeploymentHugging Face Spaces
CI/CDGitHub Actions

๐Ÿ‘ค Author

Rahul Shewatkar


๐Ÿ“„ License

MIT License