๐ Overview โข โจ Features โข ๐ธ Screenshots โข ๐ ๏ธ Tech Stack โข ๐ฆ Installation โข ๐ฅ Team
The Drug Safety Intelligence System is an end-to-end, AI-powered pharmacovigilance platform designed to analyze adverse drug events and proactively predict patient harm severity and specific reactions. Utilizing real-world clinical data, the system assists healthcare professionals and clinical researchers in early signal detection and risk assessment.
๐ฅ FDA FAERS Integration - Built on massive real-world relational databases (Year 2025) including DEMO, DRUG, REAC, THER, and OUTC.
|
Utilizes highly optimized XGBoost models for both Binary Severity Prediction (ROC-AUC: 85.08%) and Multi-class Reaction Forecasting. Programmatically tackles real-world clinical data imbalance using strategic downsampling and rigorous Target/Mean Encoding strategies. Mines integrated clinical databases to identify and flag statistically significant drug-adverse event pairs automatically. |
Refactored from a massive 2GB ensemble to a streamlined ~53MB Features both a beautiful, interactive Streamlit Dashboard for end-users and a robust FastAPI Backend for system integrations. Constructs complex feature engineering matrices directly using SQL Common Table Expressions (CTEs) without overwhelming RAM. |
| Task | Algorithm | Optimization | Performance (Test Set) |
|---|---|---|---|
| ๐ด Severity Prediction | XGBClassifier (Binary) |
scale_pos_weight=1.40, tree_method='hist' |
ROC-AUC: 85.08% Recall: 77.00% |
| ๐ Reaction Forecasting | XGBClassifier (Multi-class) |
max_depth=10, compress=9 (~53MB footprint) |
Accuracy: 72.85% (Across 20 targets) |
| Patient Risk Analysis (Matrix A & B) | Global Safety Signals Database |
![]() |
![]() |
| Demographics (Age/Weight) | Target Imbalance | Top 10 Suspect Drugs |
![]() |
![]() |
![]() |
| Polypharmacy Impact | Age by Gender | Feature Importance |
![]() |
![]() |
![]() |
| Therapy Duration Analysis | ||
![]() |
||
| Temporal Stability (Data Drift) | ||
![]() |
||
| Technology | Purpose |
|---|---|
| Core Programming Language (3.9+) | |
| Clinical Data Manipulation | |
| Mathematical Operations | |
| Relational Database Engine |
| Technology | Purpose |
|---|---|
| Preprocessing, Resampling, Metrics | |
| Tree-based Classification Algorithms | |
| Hyperparameter Tuning | |
| Advanced Model Compression |
| Technology | Purpose |
|---|---|
| High-performance RESTful API | |
| Interactive Web Dashboard | |
| CI/CD Pipeline (Linting) |
๐ Prerequisites
- โ Python 3.9 or higher
- โ Git installed
- โ Raw FDA FAERS Dataset (Not included in repo due to size)
# 1๏ธโฃ Clone the repository
git clone [https://github.com/GoldenBoy13420/Drug-Safety-Intelligence-System.git](https://github.com/GoldenBoy13420/Drug-Safety-Intelligence-System.git)
cd Drug-Safety-Intelligence-System
# 2๏ธโฃ Install dependencies
pip install -r requirements.txt
# 3๏ธโฃ Run the Streamlit Dashboard
streamlit run app.py
# 4๏ธโฃ Or Run the FastAPI Backend
uvicorn api:app --reloadTo rebuild the matrices and retrain the models from scratch:
python main.pyThis single entry point will sequentially run:
- Database Connection Validation
- Deep EDA (
eda.py) - Safety Signal Detection (
signal_detector.py) - Matrix A & B Construction (
preprocessing.py) - XGBoost Model Training & Evaluation
DRUG-SAFETY-INTELLIGENCE-SYSTEM/
โ
โโโ ๐ data/ # Raw FDA data & SQLite DB (Ignored in Git)
โโโ ๐ logs/ # System execution logs (pipeline.log)
โโโ ๐ models/ # Compressed XGBoost .pkl models & Encoders
โโโ ๐ notebooks/ # Data integration & experimental notebooks
โโโ ๐ reports/
โ โโโ ๐ figures/ # High-res EDA plots & Dashboard Screenshots
โ โโโ ๐ safety_signals_report.csv
โ
โโโ ๐ป src/ # Core Modules
โ โโโ config.py # System paths and constants
โ โโโ data_pipeline.py # Database validation
โ โโโ eda.py # Visual analysis generator
โ โโโ preprocessing.py # SQL CTEs and Matrix Building
โ โโโ model_severity.py # Binary Classification Pipeline
โ โโโ model_adverse_event.py # Multi-class Classification Pipeline
โ โโโ signal_detector.py # Pharmacovigilance Mining
โ
โโโ โก api.py # FastAPI endpoints
โโโ ๐ app.py # Streamlit UI dashboard
โโโ ๐ main.py # Full Pipeline orchestrator
โโโ ๐ requirements.txt # Cloud dependencies
Mahmoud Abdelrauf ๐ฏ AI Engineer / Lead |
Ahmed Elabd ๐ป Data Scientist |
Abdelrhman Batran ๐ป Data Scientist |
This project is licensed under the MIT License.
If you find this intelligence system helpful, please give it a star!












