This project implements an intelligent backorder prediction system using machine learning to help businesses manage their inventory effectively. The system predicts whether a product will go on backorder based on various inventory and sales features, enabling proactive inventory management decisions.
Watch the complete project walkthrough and demonstration: Project Demo Video
- Data Ingestion: Automated data loading and preprocessing from CSV files
- Data Transformation: Advanced preprocessing including outlier removal, missing value handling, and feature scaling
- Model Training: Multiple algorithm comparison (Random Forest, Decision Tree, SGD, KNN, Gradient Boosting)
- Custom Data Training: Upload your own dataset for model training
- Real-time Predictions: Web interface for individual product backorder predictions
- Model Persistence: Automated model and preprocessor saving/loading
src/logger.py: Comprehensive logging system with timestamped log filessrc/exception.py: Custom exception handling for better error managementsrc/utils.py: Utility functions for:- Object serialization/deserialization
- Outlier removal using 3-sigma rule
- Target column encoding (Yes/No β 1/0)
-
src/components/data_ingestion.py:- Handles CSV data loading
- Automated train-test split
- Configurable data paths
-
src/components/data_transformation.py:- Missing value imputation using median strategy
- Feature scaling with StandardScaler
- Data balancing using resampling techniques
- Outlier removal for both training and test data
-
src/components/model_trainer.py:- Multi-algorithm evaluation framework
- F1-score based model selection
- Automated best model selection and persistence
-
src/pipelines/prediction_pipeline.py:- Real-time prediction interface
- Custom data input handling
- Model loading and inference
-
src/pipelines/training_pipeline.py:- End-to-end training orchestration
- Pipeline coordination between components
app.py: Flask web application with:- Custom dataset upload and training
- Individual prediction interface
- File upload validation
- Error handling and user feedback
- Python 3.7 or higher
- Required packages listed in
requirements.txt
-
Clone the repository
git clone <repository-url> cd End-to-End-Intelligent-Inventory-Management-System
-
Create virtual environment
conda create -n inventory_system python=3.7 conda activate inventory_system
-
Install dependencies
pip install -r requirements.txt
python app.pyAccess the application at http://localhost:5000
from src.pipelines.training_pipeline import Training_Pipeline
# Train with default dataset
pipeline = Training_Pipeline()
result = pipeline.initiate_training_pipeline()
# Train with custom dataset
pipeline = Training_Pipeline("path/to/your/data.csv")
result = pipeline.initiate_training_pipeline()from src.pipelines.prediction_pipeline import CustomData, PredictPipeline
# Create prediction data
data = CustomData(
national_inv=24.0,
lead_time=8.0,
in_transit_qty=0.0,
forecast_3_month=3456.0,
sales_1_month=10.0,
min_bank=7.0,
perf_6_month_avg=1.0
)
# Make prediction
pipeline = PredictPipeline()
df = data.get_data_as_dataframe()
prediction = pipeline.predict(df)The model uses the following features for prediction:
national_inv: National inventory levellead_time: Lead time for product deliveryin_transit_qty: Quantity currently in transitforecast_3_month: 3-month sales forecastsales_1_month: Previous month salesmin_bank: Minimum recommended stock levelperf_6_month_avg: 6-month average performance
- Random Forest Classifier
- Decision Tree Classifier
- Stochastic Gradient Descent (SGD) Classifier
- K-Nearest Neighbors (KNN) Classifier
- Gradient Boosting Classifier
The system automatically selects the best performing model based on F1-score.
βββ src/
β βββ components/
β β βββ data_ingestion.py
β β βββ data_transformation.py
β β βββ model_trainer.py
β βββ pipelines/
β β βββ training_pipeline.py
β β βββ prediction_pipeline.py
β βββ logger.py
β βββ exception.py
β βββ utils.py
βββ notebooks/
β βββ back_order_predict.ipynb
βββ artifacts/ # Generated models and preprocessors
βββ uploads/ # User uploaded datasets
βββ templates/ # HTML templates
βββ app.py # Flask web application
βββ requirements.txt
βββ README.md
This application was previously deployed on AWS (Amazon Web Services), leveraging its robust, scalable, and reliable infrastructure. However, the deployment is currently not active.
Note: The application is not currently deployed on AWS.
The project includes a comprehensive Jupyter notebook (notebooks/back_order_predict.ipynb) with:
- Exploratory Data Analysis (EDA)
- Data preprocessing steps
- Model experimentation
- Feature correlation analysis
- Ensure all data files follow the expected schema with required columns
- The system handles class imbalance through resampling techniques
- Models are automatically saved in the
artifacts/directory - All exceptions are logged with detailed information for debugging
- Advanced feature engineering
- Hyperparameter tuning for better model performance
- Real-time data pipeline integration
- Advanced visualization dashboard
- API endpoints for system integration
Feel free to contribute to this project by:
- Reporting bugs
- Suggesting new features
- Improving documentation
- Submitting pull requests
Happy Coding! π


