A machine learning and predictive analytics web application designed to forecast hospital and pharmacy demand for critical medications. By predicting precise monthly sales, this tool empowers pharmaceutical supply chain managers to prevent life-critical drug stockouts and minimize costly inventory expiry waste.
The application provides an interactive sidebar for model tracking alongside dual-pane input controls and dynamic inventory alerts.
- Automated Data Cleaning: Cleans messy time-series records using a forward-fill (
ffill) strategy for missing pricing metrics. - Temporal Feature Engineering: Extracts 1-month/2-month sales lags, 3-month rolling averages, and a custom Winter Seasonality Index to model cold and flu spikes.
- Sequential ML Training: Trains a robust
GradientBoostingRegressorusing non-shuffled temporal splitting to mimic real-world forecasting boundaries. - Actionable Business Logic: Transforms raw mathematical floats into operational procurement advice by automatically computing a 15% safety stock buffer.
- Interactive UI: Built entirely with Streamlit, enabling users to adjust variables (competitor pricing, past sales, lag metrics) on the fly.
- User Interface: Streamlit
- Machine Learning: Scikit-Learn (
GradientBoostingRegressor) - Data Processing: Pandas, NumPy
- Environment: Jupyter Notebook / Python 3.9+
├── app.py # Core application script (Data Gen, ML Pipeline & Streamlit UI)
├── Notebook.ipynb # Sandbox notebook used for model exploration & verification
└── README.md # Project documentation
git clone https://github.com
cd pharma-sales-optimizerpip install streamlit pandas numpy scikit-learnstreamlit run app.pyThe terminal will display a local address, and the default web browser will open the user interface automatically at http://localhost:8501.
The model utilizes sequential temporal splitting instead of randomized cross-validation to prevent temporal data leakage. It scores performance using:
- R² Score (Coefficient of Determination): Evaluates trend alignment accuracy.
- RMSE (Root Mean Squared Error): Quantifies average unit deviations to track procurement margins.