One of the most common challenges in the pharmaceutical supply chain is inventory distortion — the imbalance between overstocking and understocking.
For a typical retail business, a stockout means a lost sale. In the pharmaceutical industry, the stakes are infinitely higher — it can mean a delay in life-saving treatment. This immense responsibility is why effective pharmacy inventory forecasting is not just a good business practice, but a critical component of patient safety.
PharmaCast predicts medication demand to help pharmacies:
- reduce stockouts
- avoid overstocking
- improve procurement decisions
Raw Sales Data
↓
EDA & Decomposition
↓
Feature Engineering
↓
Model Training
↓
Evaluation
↓
Inventory Insights
- Paracetamol drives 49.4% of total sales
- Annual seasonality is strong
- Weekly seasonality is negligible
- Saturday is the busiest day
- Linear Regression performed nearly as well as Random Forest
1. Clone the repository
git clone https://github.com/anaboset/FUTURE_ML_01
cd FUTURE_ML_01
pip install -r requirements.txtPlace the dataset at FUTURE_ML_01/data/pharma-sales-data/salesdaily.csv
jupyter notebook pharma_sales_forecast.ipynb
Run all cells from top to bottom. Each chapter builds on the previous one.
FUTURE_ML_01/
│
├── data/
│ └── pharma-sales-data/ # Place dataset here (not tracked by git)
│ └── salesdaily.csv
│
├── outputs/ # Generated plots saved by the notebook
│ ├── 01_exploratory_overview.png
│ ├── 01b_drug_composition.png
│ ├── 02_decomposition_comparison.png
│ ├── 03_actual_vs_predicted.png
│ ├── 04_feature_importance.png
│ ├── 05_residual_analysis.png
│ ├── 06_prediction_confidence.png
│ └── 07_scorecard.png
│
├── pharma_sales_forecast.ipynb # Full narrative analysis notebook
├── requirements.txt
├── .gitignore
└── README.md
The model was trained on a pharmacy sales dataset obtained from Kaggle, containing historical transactional sales records from 2014–2019.
The dataset is not included in this repository. To set it up locally:
Option 1 — Download manually
- Go to https://www.kaggle.com/datasets/milanzdravkovic/pharma-sales-data
- Click Download
- Extract and place
salesdaily.csvat:
FUTURE_ML_01/data/pharma-sales-data/salesdaily.csv
The notebook reads the file from this path. No other configuration is needed.
Option 2 — Download via kagglehub
pip install kagglehubimport kagglehub
from kagglehub import KaggleDatasetAdapter
df = kagglehub.load_dataset(
KaggleDatasetAdapter.PANDAS,
"milanzdravkovic/pharma-sales-data",
""
)A Kaggle account and configured API token are required for Option 2.
See Kaggle API setup for instructions.
- Cannot predict external outbreaks/events
- Requires historical sales data
- Large unexplained spikes still affect accuracy
- Retraining needed monthly
If the forecast helps a single pharmacy avoid a stockout on a critical medication, the project has achieved its purpose.
Built by AI Engineer & pharmacy student

