Back to Portfolio

AI in Healthcare: Predicting Drug Adverse Effects

Healthcare AI August 2024

Adverse drug reactions are a leading cause of morbidity and mortality, especially in vulnerable populations like neonates. Machine learning offers a promising approach to predict and prevent these adverse effects.

AI in Healthcare: Drug Adverse Effects

The Challenge: Neonatal Drug Safety

The FAERS Dataset

The FDA Adverse Event Reporting System (FAERS) provides:

ML Pipeline for ADR Prediction

1. Data Preprocessing

import pandas as pd
import numpy as np

# Filter neonatal cases (age 0-28 days)
neonatal_data = faers_data[faers_data['age_days'] <= 28]

# Clean and standardize drug names
neonatal_data['drug_clean'] = neonatal_data['drug_name'].str.lower().str.strip()

# Handle missing values
neonatal_data['weight'].fillna(neonatal_data['weight'].median(), inplace=True)

2. Feature Engineering

# Patient demographics
features = ['age_days', 'weight_kg', 'gestational_age', 'sex']

# Drug characteristics
features += ['drug_class', 'route_of_admin', 'dosage_form']

# Interaction features (polypharmacy)
neonatal_data['drug_count'] = neonatal_data.groupby('case_id')['drug_name'].transform('count')
features += ['drug_count']

3. Model Training with Class Imbalance Handling

from imblearn.over_sampling import SMOTE
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

# Handle class imbalance
smote = SMOTE(random_state=42)
X_resampled, y_resampled = smote.fit_resample(X_train, y_train)

# Train model
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_resampled, y_resampled)

Explainable AI with SHAP

import shap

# Create explainer
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)

# Visualize feature importance
shap.summary_plot(shap_values[1], X_test)

Evaluation Metrics for Healthcare

Clinical Integration Considerations

Impact: By combining ML with clinical expertise, we can enhance neonatal patient safety and improve care outcomes while maintaining ethical AI practices.

Back to Portfolio