Datasets:
Upload folder using huggingface_hub
Browse files- README.md +153 -0
- data/warehouse_district_store.csv +0 -0
- data/warehouse_national_central_medical_store.csv +0 -0
- data/warehouse_regional_warehouse.csv +0 -0
- generate_dataset.py +238 -0
- requirements.txt +3 -0
- validate_dataset.py +107 -0
- validation_report.png +3 -0
README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
- tabular-regression
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- healthcare
|
| 10 |
+
- supply-chain
|
| 11 |
+
- warehouse
|
| 12 |
+
- inventory
|
| 13 |
+
- storage
|
| 14 |
+
- GDP
|
| 15 |
+
- FEFO
|
| 16 |
+
- wastage
|
| 17 |
+
- central-medical-store
|
| 18 |
+
- sub-saharan-africa
|
| 19 |
+
- lmic
|
| 20 |
+
pretty_name: "Warehouse & Inventory Management (Inventory Accuracy, Storage Conditions, Wastage, FEFO Compliance)"
|
| 21 |
+
size_categories:
|
| 22 |
+
- 10K<n<100K
|
| 23 |
+
configs:
|
| 24 |
+
- config_name: national_central_medical_store
|
| 25 |
+
data_files: data/warehouse_national_central_medical_store.csv
|
| 26 |
+
- config_name: regional_warehouse
|
| 27 |
+
data_files: data/warehouse_regional_warehouse.csv
|
| 28 |
+
default: true
|
| 29 |
+
- config_name: district_store
|
| 30 |
+
data_files: data/warehouse_district_store.csv
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
# Warehouse & Inventory Management Dataset
|
| 34 |
+
|
| 35 |
+
## Abstract
|
| 36 |
+
|
| 37 |
+
This dataset provides **30,000 simulated warehouse-level observations** (10,000 per scenario) of health commodity storage, inventory management, and warehousing performance across three tiers of the pharmaceutical supply chain in sub-Saharan Africa. Each record represents one commodity category assessed at one warehouse during one monthly period. The dataset captures 40+ variables spanning warehouse infrastructure, storage conditions, inventory accuracy, FEFO compliance, order fulfilment, wastage (expiry + damage), capacity utilisation, temperature excursions, pest damage, theft, and downstream facility impact. Three scenarios: national CMS (82% inventory accuracy), regional warehouse (55%), district store (28%).
|
| 38 |
+
|
| 39 |
+
**This dataset is entirely simulated. It must not be used for warehouse operations or procurement decisions.**
|
| 40 |
+
|
| 41 |
+
## 1. Introduction
|
| 42 |
+
|
| 43 |
+
### 1.1 Warehouse Management in Health Supply Chains
|
| 44 |
+
|
| 45 |
+
Warehousing is the critical link between procurement and last-mile distribution. USAID GHSC-PSM has documented that effective warehouse management — including proper storage conditions, inventory accuracy, and FEFO (First Expiry, First Out) compliance — directly impacts commodity availability at health facilities.
|
| 46 |
+
|
| 47 |
+
### 1.2 Storage Conditions
|
| 48 |
+
|
| 49 |
+
WHO Good Distribution Practices (GDP) require controlled temperature, humidity, pest management, and security for pharmaceutical storage. However, UNICEF Supply Division assessments indicate that only 40-60% of SSA warehouses meet WHO GDP standards, with district-level stores frequently lacking basic infrastructure including temperature monitoring, generator backup, and pest control.
|
| 50 |
+
|
| 51 |
+
### 1.3 Inventory Accuracy and Wastage
|
| 52 |
+
|
| 53 |
+
Stock record discrepancies between physical counts and records are widespread, with inventory accuracy as low as 25-30% at district stores. Wastage from expired and damaged stock reaches 15-30% at sub-national levels, representing significant financial losses and contributing to downstream stockouts.
|
| 54 |
+
|
| 55 |
+
### 1.4 Rationale
|
| 56 |
+
|
| 57 |
+
This dataset integrates warehouse infrastructure, storage quality, inventory management performance, and downstream impact indicators for supply chain optimization research and warehouse management system development.
|
| 58 |
+
|
| 59 |
+
## 2. Methodology
|
| 60 |
+
|
| 61 |
+
### 2.1 Parameterization
|
| 62 |
+
|
| 63 |
+
| Parameter | National CMS | Regional WH | District Store | Source |
|
| 64 |
+
| --- | --- | --- | --- | --- |
|
| 65 |
+
| Inventory accuracy | 82% | 55% | 28% | JSI/SIAPS assessments |
|
| 66 |
+
| Order fulfilment | 78% | 52% | 30% | GHSC-PSM data |
|
| 67 |
+
| Wastage rate | 8% | 18% | 30% | Warehouse audits |
|
| 68 |
+
| Storage adequate | 75% | 42% | 15% | UNICEF assessments |
|
| 69 |
+
| FEFO compliance | 70% | 35% | 10% | WHO GDP audits |
|
| 70 |
+
| Capacity utilisation | 85% | 65% | 40% | Infrastructure data |
|
| 71 |
+
|
| 72 |
+
### 2.2 Commodity Categories
|
| 73 |
+
|
| 74 |
+
12 categories: essential medicines, ARVs, vaccines (cold chain), laboratory reagents (cold chain), contraceptives, malaria commodities, IV fluids, PPE/IPC supplies, surgical supplies, nutrition commodities, medical device consumables, controlled substances (secure storage).
|
| 75 |
+
|
| 76 |
+
## 3. Schema
|
| 77 |
+
|
| 78 |
+
| Column | Type | Description |
|
| 79 |
+
| --- | --- | --- |
|
| 80 |
+
| warehouse_level | categorical | national_CMS / regional_warehouse / district_store |
|
| 81 |
+
| warehouse_size_sqm | int | Storage area in square metres |
|
| 82 |
+
| commodity_category | categorical | 12 commodity categories |
|
| 83 |
+
| storage_requirement | categorical | ambient / cold_chain_2_8C / secure_ambient |
|
| 84 |
+
| criticality | categorical | critical / high / medium / low |
|
| 85 |
+
| has_WMS | binary | Warehouse management system |
|
| 86 |
+
| has_temperature_monitoring | binary | Temperature monitoring |
|
| 87 |
+
| has_generator_backup | binary | Backup power |
|
| 88 |
+
| storage_conditions_adequate | binary | Meets GDP standards |
|
| 89 |
+
| inventory_accuracy_pct | float | Physical vs record match |
|
| 90 |
+
| stock_record_up_to_date | binary | Records current |
|
| 91 |
+
| fefo_compliance | binary | FEFO practiced |
|
| 92 |
+
| order_fulfilment_rate_pct | float | Orders fulfilled completely |
|
| 93 |
+
| orders_backordered | int | Unfulfilled orders |
|
| 94 |
+
| wastage_rate_pct | float | Expired + damaged rate |
|
| 95 |
+
| expired_stock_value_usd | float | Value of expired stock |
|
| 96 |
+
| capacity_utilisation_pct | float | Space used |
|
| 97 |
+
| temperature_excursion_month | int | Cold chain breaks |
|
| 98 |
+
| pest_damage_reported | binary | Pest damage |
|
| 99 |
+
| theft_reported | binary | Theft/pilferage |
|
| 100 |
+
| inventory_issue | categorical | 11 issue categories |
|
| 101 |
+
| stockout_at_warehouse | binary | Warehouse-level stockout |
|
| 102 |
+
| facilities_affected_by_stockout | int | Downstream facilities impacted |
|
| 103 |
+
|
| 104 |
+
## 4. Validation
|
| 105 |
+
|
| 106 |
+
<p align="center">
|
| 107 |
+
<img src="validation_report.png" alt="Validation Report" width="100%">
|
| 108 |
+
</p>
|
| 109 |
+
|
| 110 |
+
## 5. Usage
|
| 111 |
+
|
| 112 |
+
```python
|
| 113 |
+
from datasets import load_dataset
|
| 114 |
+
|
| 115 |
+
dataset = load_dataset(
|
| 116 |
+
"electricsheepafrica/warehouse-inventory-management",
|
| 117 |
+
"regional_warehouse"
|
| 118 |
+
)
|
| 119 |
+
df = dataset["train"].to_pandas()
|
| 120 |
+
|
| 121 |
+
# Wastage by commodity category
|
| 122 |
+
print(df.groupby('commodity_category')['wastage_rate_pct'].mean().sort_values(ascending=False))
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
## 6. Limitations
|
| 126 |
+
|
| 127 |
+
- **Simulated**: Not from real WMS data or warehouse audits.
|
| 128 |
+
- **No seasonal effects**: Humidity/temperature seasonal variation not modelled.
|
| 129 |
+
- **Simplified costing**: Wastage costs are estimates, not actual financial records.
|
| 130 |
+
|
| 131 |
+
## 7. References
|
| 132 |
+
|
| 133 |
+
1. USAID GHSC-PSM. Warehouse management best practices.
|
| 134 |
+
2. WHO (2014). Good storage and distribution practices (GDP).
|
| 135 |
+
3. JSI/SIAPS. Strengthening pharmaceutical supply chains.
|
| 136 |
+
4. UNICEF Supply Division. Warehouse capacity assessments.
|
| 137 |
+
|
| 138 |
+
## Citation
|
| 139 |
+
|
| 140 |
+
```bibtex
|
| 141 |
+
@dataset{esa_warehouse_inventory_2025,
|
| 142 |
+
title = {Warehouse and Inventory Management Dataset},
|
| 143 |
+
author = {{Electric Sheep Africa}},
|
| 144 |
+
year = {2025},
|
| 145 |
+
publisher = {Hugging Face},
|
| 146 |
+
url = {https://huggingface.co/datasets/electricsheepafrica/warehouse-inventory-management},
|
| 147 |
+
note = {Simulated dataset. Not for warehouse operations or procurement decisions.}
|
| 148 |
+
}
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
## License
|
| 152 |
+
|
| 153 |
+
[CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/)
|
data/warehouse_district_store.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/warehouse_national_central_medical_store.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/warehouse_regional_warehouse.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Literature-Informed Warehouse & Inventory Management Dataset
|
| 4 |
+
==============================================================
|
| 5 |
+
|
| 6 |
+
Each record = ONE warehouse/store observation for ONE commodity
|
| 7 |
+
category during ONE monthly reporting period.
|
| 8 |
+
|
| 9 |
+
Sources:
|
| 10 |
+
[1] USAID GHSC-PSM. Warehouse management best practices. Storage
|
| 11 |
+
conditions, inventory accuracy, order fulfilment.
|
| 12 |
+
[2] WHO (2014). Good storage and distribution practices. Temperature,
|
| 13 |
+
humidity, pest control, FEFO compliance.
|
| 14 |
+
[3] JSI/SIAPS. Strengthening pharmaceutical supply chains.
|
| 15 |
+
Inventory accuracy, stock record discrepancies.
|
| 16 |
+
[4] UNICEF Supply Division. Warehouse capacity assessments.
|
| 17 |
+
Only 40-60% of SSA warehouses meet WHO GDP standards.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
import numpy as np
|
| 21 |
+
import pandas as pd
|
| 22 |
+
import argparse
|
| 23 |
+
import os
|
| 24 |
+
|
| 25 |
+
COMMODITY_CATEGORIES = [
|
| 26 |
+
('essential_medicines', 'ambient', 'high', 0.35),
|
| 27 |
+
('ARVs', 'ambient', 'high', 0.15),
|
| 28 |
+
('vaccines', 'cold_chain_2_8C', 'critical', 0.08),
|
| 29 |
+
('laboratory_reagents', 'cold_chain_2_8C', 'medium', 0.05),
|
| 30 |
+
('contraceptives', 'ambient', 'medium', 0.08),
|
| 31 |
+
('malaria_commodities', 'ambient', 'high', 0.10),
|
| 32 |
+
('IV_fluids', 'ambient', 'high', 0.05),
|
| 33 |
+
('PPE_IPC_supplies', 'ambient', 'medium', 0.04),
|
| 34 |
+
('surgical_supplies', 'ambient', 'medium', 0.03),
|
| 35 |
+
('nutrition_commodities', 'ambient', 'medium', 0.03),
|
| 36 |
+
('medical_devices_consumables', 'ambient', 'low', 0.02),
|
| 37 |
+
('controlled_substances', 'secure_ambient', 'critical', 0.02),
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
INVENTORY_ISSUES = [
|
| 41 |
+
'stock_record_discrepancy', 'expired_stock', 'damaged_goods',
|
| 42 |
+
'theft_pilferage', 'pest_infestation', 'temperature_excursion',
|
| 43 |
+
'overstocking', 'understocking', 'FEFO_not_followed',
|
| 44 |
+
'receiving_error', 'dispatch_error',
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
SCENARIOS = {
|
| 48 |
+
'national_central_medical_store': {
|
| 49 |
+
'warehouse_level': 'national_CMS',
|
| 50 |
+
'warehouse_size_sqm': 5000,
|
| 51 |
+
'has_WMS': True,
|
| 52 |
+
'has_temperature_monitoring': True,
|
| 53 |
+
'has_generator_backup': True,
|
| 54 |
+
'has_pest_control': True,
|
| 55 |
+
'has_security_system': True,
|
| 56 |
+
'staff_count': 40,
|
| 57 |
+
'inventory_accuracy_rate': 0.82,
|
| 58 |
+
'order_fulfilment_rate': 0.78,
|
| 59 |
+
'wastage_rate': 0.08,
|
| 60 |
+
'storage_conditions_adequate': 0.75,
|
| 61 |
+
'fefo_compliance': 0.70,
|
| 62 |
+
'stock_record_up_to_date': 0.80,
|
| 63 |
+
'capacity_utilisation': 0.85,
|
| 64 |
+
},
|
| 65 |
+
'regional_warehouse': {
|
| 66 |
+
'warehouse_level': 'regional_warehouse',
|
| 67 |
+
'warehouse_size_sqm': 1500,
|
| 68 |
+
'has_WMS': False,
|
| 69 |
+
'has_temperature_monitoring': False,
|
| 70 |
+
'has_generator_backup': False,
|
| 71 |
+
'has_pest_control': False,
|
| 72 |
+
'has_security_system': False,
|
| 73 |
+
'staff_count': 12,
|
| 74 |
+
'inventory_accuracy_rate': 0.55,
|
| 75 |
+
'order_fulfilment_rate': 0.52,
|
| 76 |
+
'wastage_rate': 0.18,
|
| 77 |
+
'storage_conditions_adequate': 0.42,
|
| 78 |
+
'fefo_compliance': 0.35,
|
| 79 |
+
'stock_record_up_to_date': 0.45,
|
| 80 |
+
'capacity_utilisation': 0.65,
|
| 81 |
+
},
|
| 82 |
+
'district_store': {
|
| 83 |
+
'warehouse_level': 'district_store',
|
| 84 |
+
'warehouse_size_sqm': 200,
|
| 85 |
+
'has_WMS': False,
|
| 86 |
+
'has_temperature_monitoring': False,
|
| 87 |
+
'has_generator_backup': False,
|
| 88 |
+
'has_pest_control': False,
|
| 89 |
+
'has_security_system': False,
|
| 90 |
+
'staff_count': 3,
|
| 91 |
+
'inventory_accuracy_rate': 0.28,
|
| 92 |
+
'order_fulfilment_rate': 0.30,
|
| 93 |
+
'wastage_rate': 0.30,
|
| 94 |
+
'storage_conditions_adequate': 0.15,
|
| 95 |
+
'fefo_compliance': 0.10,
|
| 96 |
+
'stock_record_up_to_date': 0.15,
|
| 97 |
+
'capacity_utilisation': 0.40,
|
| 98 |
+
},
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def generate_dataset(n=10000, seed=42, scenario='regional_warehouse'):
|
| 103 |
+
rng = np.random.default_rng(seed)
|
| 104 |
+
sc = SCENARIOS[scenario]
|
| 105 |
+
records = []
|
| 106 |
+
n_cat = len(COMMODITY_CATEGORIES)
|
| 107 |
+
|
| 108 |
+
for idx in range(n):
|
| 109 |
+
rec = {'id': idx + 1}
|
| 110 |
+
rec['warehouse_level'] = sc['warehouse_level']
|
| 111 |
+
rec['warehouse_id'] = f"WH_{rng.integers(1, 100):04d}"
|
| 112 |
+
rec['warehouse_size_sqm'] = max(20, int(rng.normal(
|
| 113 |
+
sc['warehouse_size_sqm'], sc['warehouse_size_sqm'] * 0.3)))
|
| 114 |
+
rec['region_type'] = rng.choice(['urban', 'peri_urban', 'rural'],
|
| 115 |
+
p=[0.05, 0.15, 0.80] if scenario == 'district_store'
|
| 116 |
+
else ([0.60, 0.25, 0.15] if scenario == 'national_central_medical_store'
|
| 117 |
+
else [0.25, 0.40, 0.35]))
|
| 118 |
+
rec['has_WMS'] = 1 if sc['has_WMS'] else (1 if rng.random() < 0.05 else 0)
|
| 119 |
+
rec['has_temperature_monitoring'] = 1 if sc['has_temperature_monitoring'] else (
|
| 120 |
+
1 if rng.random() < 0.08 else 0)
|
| 121 |
+
rec['has_generator_backup'] = 1 if sc['has_generator_backup'] else (
|
| 122 |
+
1 if rng.random() < 0.10 else 0)
|
| 123 |
+
rec['has_pest_control'] = 1 if sc['has_pest_control'] else (
|
| 124 |
+
1 if rng.random() < 0.08 else 0)
|
| 125 |
+
rec['has_security_system'] = 1 if sc['has_security_system'] else (
|
| 126 |
+
1 if rng.random() < 0.05 else 0)
|
| 127 |
+
rec['staff_count'] = max(1, int(rng.poisson(sc['staff_count'])))
|
| 128 |
+
rec['staff_trained_gdp'] = 1 if rng.random() < (
|
| 129 |
+
0.70 if scenario == 'national_central_medical_store' else
|
| 130 |
+
(0.25 if scenario == 'regional_warehouse' else 0.05)) else 0
|
| 131 |
+
|
| 132 |
+
cat_idx = idx % n_cat
|
| 133 |
+
cat = COMMODITY_CATEGORIES[cat_idx]
|
| 134 |
+
rec['commodity_category'] = cat[0]
|
| 135 |
+
rec['storage_requirement'] = cat[1]
|
| 136 |
+
rec['criticality'] = cat[2]
|
| 137 |
+
rec['volume_share_pct'] = cat[3] * 100
|
| 138 |
+
|
| 139 |
+
rec['year'] = rng.choice([2021, 2022, 2023, 2024], p=[0.15, 0.25, 0.30, 0.30])
|
| 140 |
+
rec['month'] = rng.integers(1, 13)
|
| 141 |
+
|
| 142 |
+
rec['storage_conditions_adequate'] = 1 if rng.random() < sc['storage_conditions_adequate'] else 0
|
| 143 |
+
if cat[1] in ('cold_chain_2_8C',) and not rec['has_temperature_monitoring']:
|
| 144 |
+
rec['storage_conditions_adequate'] = 1 if rng.random() < 0.10 else 0
|
| 145 |
+
if cat[1] == 'secure_ambient' and not rec['has_security_system']:
|
| 146 |
+
rec['storage_conditions_adequate'] = 1 if rng.random() < 0.15 else 0
|
| 147 |
+
|
| 148 |
+
rec['inventory_accuracy_pct'] = round(np.clip(
|
| 149 |
+
rng.normal(sc['inventory_accuracy_rate'] * 100, 12), 10, 100), 1)
|
| 150 |
+
rec['stock_record_up_to_date'] = 1 if rng.random() < sc['stock_record_up_to_date'] else 0
|
| 151 |
+
rec['fefo_compliance'] = 1 if rng.random() < sc['fefo_compliance'] else 0
|
| 152 |
+
|
| 153 |
+
rec['order_fulfilment_rate_pct'] = round(np.clip(
|
| 154 |
+
rng.normal(sc['order_fulfilment_rate'] * 100, 15), 5, 100), 1)
|
| 155 |
+
rec['orders_received_month'] = max(0, int(rng.poisson(
|
| 156 |
+
50 if scenario == 'national_central_medical_store' else
|
| 157 |
+
(15 if scenario == 'regional_warehouse' else 5))))
|
| 158 |
+
rec['orders_fulfilled_complete'] = max(0, min(rec['orders_received_month'],
|
| 159 |
+
int(rec['orders_received_month'] * rec['order_fulfilment_rate_pct'] / 100)))
|
| 160 |
+
rec['orders_backordered'] = rec['orders_received_month'] - rec['orders_fulfilled_complete']
|
| 161 |
+
|
| 162 |
+
rec['wastage_rate_pct'] = round(np.clip(
|
| 163 |
+
rng.normal(sc['wastage_rate'] * 100, 5), 0.5, 50), 1)
|
| 164 |
+
rec['expired_stock_value_usd'] = max(0, round(rng.exponential(
|
| 165 |
+
5000 if scenario == 'national_central_medical_store' else
|
| 166 |
+
(1000 if scenario == 'regional_warehouse' else 100)), 0))
|
| 167 |
+
rec['damaged_goods_value_usd'] = max(0, round(rng.exponential(
|
| 168 |
+
500 if scenario == 'national_central_medical_store' else
|
| 169 |
+
(200 if scenario == 'regional_warehouse' else 30)), 0))
|
| 170 |
+
|
| 171 |
+
rec['capacity_utilisation_pct'] = round(np.clip(
|
| 172 |
+
rng.normal(sc['capacity_utilisation'] * 100, 15), 5, 110), 1)
|
| 173 |
+
rec['overflow_to_other_space'] = 1 if rec['capacity_utilisation_pct'] > 95 else 0
|
| 174 |
+
|
| 175 |
+
rec['temperature_excursion_month'] = 0
|
| 176 |
+
if cat[1] in ('cold_chain_2_8C',):
|
| 177 |
+
rec['temperature_excursion_month'] = max(0, int(rng.poisson(
|
| 178 |
+
0.5 if scenario == 'national_central_medical_store' else
|
| 179 |
+
(2 if scenario == 'regional_warehouse' else 5))))
|
| 180 |
+
rec['pest_damage_reported'] = 1 if rng.random() < (
|
| 181 |
+
0.03 if scenario == 'national_central_medical_store' else
|
| 182 |
+
(0.12 if scenario == 'regional_warehouse' else 0.25)) else 0
|
| 183 |
+
rec['theft_reported'] = 1 if rng.random() < (
|
| 184 |
+
0.02 if scenario == 'national_central_medical_store' else
|
| 185 |
+
(0.05 if scenario == 'regional_warehouse' else 0.10)) else 0
|
| 186 |
+
|
| 187 |
+
rec['inventory_issue'] = 'none'
|
| 188 |
+
if rec['inventory_accuracy_pct'] < 80 or rec['wastage_rate_pct'] > 15:
|
| 189 |
+
if scenario == 'district_store':
|
| 190 |
+
issue_p = [0.15, 0.18, 0.08, 0.08, 0.05, 0.05, 0.08, 0.12, 0.10, 0.05, 0.06]
|
| 191 |
+
elif scenario == 'regional_warehouse':
|
| 192 |
+
issue_p = [0.15, 0.15, 0.08, 0.05, 0.08, 0.08, 0.10, 0.10, 0.08, 0.06, 0.07]
|
| 193 |
+
else:
|
| 194 |
+
issue_p = [0.12, 0.10, 0.08, 0.05, 0.05, 0.05, 0.15, 0.10, 0.10, 0.10, 0.10]
|
| 195 |
+
rec['inventory_issue'] = rng.choice(INVENTORY_ISSUES, p=issue_p)
|
| 196 |
+
|
| 197 |
+
rec['stockout_at_warehouse'] = 1 if rng.random() < (
|
| 198 |
+
0.10 if scenario == 'national_central_medical_store' else
|
| 199 |
+
(0.30 if scenario == 'regional_warehouse' else 0.55)) else 0
|
| 200 |
+
rec['facilities_affected_by_stockout'] = 0
|
| 201 |
+
if rec['stockout_at_warehouse']:
|
| 202 |
+
rec['facilities_affected_by_stockout'] = max(0, int(rng.exponential(
|
| 203 |
+
20 if scenario == 'national_central_medical_store' else
|
| 204 |
+
(8 if scenario == 'regional_warehouse' else 2))))
|
| 205 |
+
|
| 206 |
+
rec['report_submitted'] = 1 if rng.random() < (
|
| 207 |
+
0.90 if scenario == 'national_central_medical_store' else
|
| 208 |
+
(0.50 if scenario == 'regional_warehouse' else 0.15)) else 0
|
| 209 |
+
|
| 210 |
+
records.append(rec)
|
| 211 |
+
|
| 212 |
+
df = pd.DataFrame(records)
|
| 213 |
+
print(f"\n{'='*65}")
|
| 214 |
+
print(f"Warehouse & Inventory — {scenario} (n={n}, seed={seed})")
|
| 215 |
+
print(f"{'='*65}")
|
| 216 |
+
print(f" Inventory accuracy: {df['inventory_accuracy_pct'].mean():.1f}%")
|
| 217 |
+
print(f" Order fulfilment: {df['order_fulfilment_rate_pct'].mean():.1f}%")
|
| 218 |
+
print(f" Wastage rate: {df['wastage_rate_pct'].mean():.1f}%")
|
| 219 |
+
print(f" Storage adequate: {df['storage_conditions_adequate'].mean()*100:.1f}%")
|
| 220 |
+
print(f" FEFO compliance: {df['fefo_compliance'].mean()*100:.1f}%")
|
| 221 |
+
return df
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
if __name__ == '__main__':
|
| 225 |
+
parser = argparse.ArgumentParser()
|
| 226 |
+
parser.add_argument('--all-scenarios', action='store_true')
|
| 227 |
+
parser.add_argument('--n', type=int, default=10000)
|
| 228 |
+
parser.add_argument('--seed', type=int, default=42)
|
| 229 |
+
args = parser.parse_args()
|
| 230 |
+
os.makedirs('data', exist_ok=True)
|
| 231 |
+
if args.all_scenarios:
|
| 232 |
+
for sc in SCENARIOS:
|
| 233 |
+
df = generate_dataset(n=args.n, seed=args.seed, scenario=sc)
|
| 234 |
+
df.to_csv(os.path.join('data', f'warehouse_{sc}.csv'), index=False)
|
| 235 |
+
print(f" -> Saved\n")
|
| 236 |
+
else:
|
| 237 |
+
df = generate_dataset(n=args.n, seed=args.seed)
|
| 238 |
+
df.to_csv(os.path.join('data', 'warehouse_regional_warehouse.csv'), index=False)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy>=1.24
|
| 2 |
+
pandas>=2.0
|
| 3 |
+
matplotlib>=3.7
|
validate_dataset.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Validation & Diagnostic Visualization for Warehouse & Inventory Management Dataset."""
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import numpy as np
|
| 6 |
+
import matplotlib.pyplot as plt
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
SCENARIOS = ['national_central_medical_store', 'regional_warehouse', 'district_store']
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def load_scenarios(data_dir='data'):
|
| 13 |
+
dfs = {}
|
| 14 |
+
for sc in SCENARIOS:
|
| 15 |
+
path = os.path.join(data_dir, f'warehouse_{sc}.csv')
|
| 16 |
+
if os.path.exists(path):
|
| 17 |
+
dfs[sc] = pd.read_csv(path)
|
| 18 |
+
return dfs
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def make_report(dfs, output='validation_report.png'):
|
| 22 |
+
fig, axes = plt.subplots(4, 2, figsize=(16, 24))
|
| 23 |
+
fig.suptitle(
|
| 24 |
+
'Warehouse & Inventory Management — Validation Report\n'
|
| 25 |
+
'(National CMS → Regional Warehouse → District Store)',
|
| 26 |
+
fontsize=15, fontweight='bold', y=0.99)
|
| 27 |
+
colors = ['#2ecc71', '#f39c12', '#e74c3c']
|
| 28 |
+
x = np.arange(len(SCENARIOS))
|
| 29 |
+
labels = ['National CMS', 'Regional WH', 'District Store']
|
| 30 |
+
|
| 31 |
+
ax = axes[0, 0]
|
| 32 |
+
inv = [dfs[sc]['inventory_accuracy_pct'].mean() for sc in SCENARIOS if sc in dfs]
|
| 33 |
+
ax.bar(x, inv, color=colors, alpha=0.8)
|
| 34 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 35 |
+
for i, v in enumerate(inv):
|
| 36 |
+
ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
|
| 37 |
+
ax.set_ylabel('Accuracy (%)'); ax.set_title('Inventory Accuracy'); ax.set_ylim(0,100)
|
| 38 |
+
|
| 39 |
+
ax = axes[0, 1]
|
| 40 |
+
ofr = [dfs[sc]['order_fulfilment_rate_pct'].mean() for sc in SCENARIOS if sc in dfs]
|
| 41 |
+
ax.bar(x, ofr, color=colors, alpha=0.8)
|
| 42 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 43 |
+
for i, v in enumerate(ofr):
|
| 44 |
+
ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
|
| 45 |
+
ax.set_ylabel('Fulfilment (%)'); ax.set_title('Order Fulfilment Rate')
|
| 46 |
+
|
| 47 |
+
ax = axes[1, 0]
|
| 48 |
+
waste = [dfs[sc]['wastage_rate_pct'].mean() for sc in SCENARIOS if sc in dfs]
|
| 49 |
+
ax.bar(x, waste, color=colors, alpha=0.8)
|
| 50 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 51 |
+
for i, v in enumerate(waste):
|
| 52 |
+
ax.text(i, v+0.5, f'{v:.1f}%', ha='center', fontsize=10, fontweight='bold')
|
| 53 |
+
ax.set_ylabel('Wastage (%)'); ax.set_title('Wastage Rate (Expired + Damaged)')
|
| 54 |
+
|
| 55 |
+
ax = axes[1, 1]
|
| 56 |
+
fefo = [dfs[sc]['fefo_compliance'].mean()*100 for sc in SCENARIOS if sc in dfs]
|
| 57 |
+
ax.bar(x, fefo, color=colors, alpha=0.8)
|
| 58 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 59 |
+
for i, v in enumerate(fefo):
|
| 60 |
+
ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
|
| 61 |
+
ax.set_ylabel('Compliance (%)'); ax.set_title('FEFO Compliance')
|
| 62 |
+
|
| 63 |
+
ax = axes[2, 0]
|
| 64 |
+
df = dfs.get('regional_warehouse', list(dfs.values())[0])
|
| 65 |
+
issue_df = df[df['inventory_issue']!='none']
|
| 66 |
+
if len(issue_df)>0:
|
| 67 |
+
issues = issue_df['inventory_issue'].value_counts().head(8)
|
| 68 |
+
ax.barh(range(len(issues)), issues.values, color='#e74c3c', alpha=0.7)
|
| 69 |
+
ax.set_yticks(range(len(issues)))
|
| 70 |
+
ax.set_yticklabels([s.replace('_',' ').title() for s in issues.index], fontsize=7)
|
| 71 |
+
ax.set_xlabel('Count')
|
| 72 |
+
ax.set_title('Top Inventory Issues (Regional)')
|
| 73 |
+
|
| 74 |
+
ax = axes[2, 1]
|
| 75 |
+
stor = [dfs[sc]['storage_conditions_adequate'].mean()*100 for sc in SCENARIOS if sc in dfs]
|
| 76 |
+
ax.bar(x, stor, color=colors, alpha=0.8)
|
| 77 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 78 |
+
for i, v in enumerate(stor):
|
| 79 |
+
ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
|
| 80 |
+
ax.set_ylabel('Rate (%)'); ax.set_title('Storage Conditions Adequate')
|
| 81 |
+
|
| 82 |
+
ax = axes[3, 0]
|
| 83 |
+
cap = [dfs[sc]['capacity_utilisation_pct'].mean() for sc in SCENARIOS if sc in dfs]
|
| 84 |
+
ax.bar(x, cap, color=colors, alpha=0.8)
|
| 85 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 86 |
+
for i, v in enumerate(cap):
|
| 87 |
+
ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
|
| 88 |
+
ax.set_ylabel('Utilisation (%)'); ax.set_title('Warehouse Capacity Utilisation')
|
| 89 |
+
|
| 90 |
+
ax = axes[3, 1]
|
| 91 |
+
so = [dfs[sc]['stockout_at_warehouse'].mean()*100 for sc in SCENARIOS if sc in dfs]
|
| 92 |
+
ax.bar(x, so, color=colors, alpha=0.8)
|
| 93 |
+
ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
|
| 94 |
+
for i, v in enumerate(so):
|
| 95 |
+
ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
|
| 96 |
+
ax.set_ylabel('Rate (%)'); ax.set_title('Stockout at Warehouse Level')
|
| 97 |
+
|
| 98 |
+
plt.tight_layout(rect=[0,0,1,0.97])
|
| 99 |
+
plt.savefig(output, dpi=150, bbox_inches='tight')
|
| 100 |
+
print(f'Saved validation report to {output}')
|
| 101 |
+
plt.close()
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
if __name__ == '__main__':
|
| 105 |
+
dfs = load_scenarios()
|
| 106 |
+
if dfs:
|
| 107 |
+
make_report(dfs)
|
validation_report.png
ADDED
|
Git LFS Details
|