Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Pharma Sales & Inventory Optimizer (Regression)

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.

Live Interface Preview

The application provides an interactive sidebar for model tracking alongside dual-pane input controls and dynamic inventory alerts.

Features

  • 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 GradientBoostingRegressor using 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.

Tech Stack & Core Libraries

  • User Interface: Streamlit
  • Machine Learning: Scikit-Learn (GradientBoostingRegressor)
  • Data Processing: Pandas, NumPy
  • Environment: Jupyter Notebook / Python 3.9+

Repository Structure

├── app.py                 # Core application script (Data Gen, ML Pipeline & Streamlit UI)
├── Notebook.ipynb         # Sandbox notebook used for model exploration & verification
└── README.md              # Project documentation

How to Run Locally

1. Clone the repository

git clone https://github.com
cd pharma-sales-optimizer

2. Install dependencies

pip install streamlit pandas numpy scikit-learn

3. Launch the Application

streamlit run app.py

The terminal will display a local address, and the default web browser will open the user interface automatically at http://localhost:8501.

Evaluation & Validation Metrics

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.

About

This data science project builds an interactive machine learning dashboard using Pandas, NumPy, Scikit-Learn, and Streamlit to forecast pharmaceutical demand, preventing critical drug stockouts and inventory waste.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages