MABONGALABS commited on
Commit
583d0d9
·
verified ·
1 Parent(s): 575b95a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -17
README.md CHANGED
@@ -5,28 +5,65 @@ emoji: 🩸
5
  colorFrom: red
6
  colorTo: gray
7
  sdk: gradio
8
- sdk_version: "4.0"
9
  app_file: app.py
10
  pinned: false
 
 
 
 
 
 
11
  ---
12
 
13
- # Explainable AI-Driven Ensemble Model for Malaria and Sickle Cell Anemia Classification in Western Kenya
14
 
15
- ## Project Overview
16
- The **Hemaclass AI Diagnostics** dashboard is a Phase 4 prototype designed to classify multi-class hematological diseases (Malaria, Sickle Cell Anemia, Co-infections, and Negative cases) using a highly optimized, stacked ensemble machine learning architecture.
17
 
18
- ## Clinical Decision Support
19
- The tool is designed as an assistive diagnostic dashboard. Clinicians can input manual patient vitals and lab results (e.g., Hemoglobin, WBC count, Malaria RDT) or batch upload retrospective `.csv` clinical data to receive:
20
- 1. **AI Diagnosis:** Fast classification of the patient's condition.
21
- 2. **Confidence Score:** Probabilistic output from the meta-learner.
22
- 3. **Clinical Recommendations:** Automated WHO-aligned protocol suggestions based on severity (e.g., hyperhemolytic crisis alerts).
23
- 4. **XAI Interpretability:** Local SHAP (SHapley Additive exPlanations) waterfall plots explaining exactly *why* the AI made the decision.
24
 
25
- ## Model Architecture
26
- - **Base Learners:** Random Forest, Support Vector Machine (RBF Kernel), XGBoost.
27
- - **Meta-Learner:** Logistic Regression (Stacking Classifier).
28
- - **Preprocessing:** MICE Imputation, SMOTE Data Balancing, robust Z-Score Normalization.
29
- - **Optimization:** ~30 minute Bayesian Search CV (Nested 5-Fold) to guarantee robust generalization without overfitting.
30
 
31
- ## Ethical & Regulatory Compliance
32
- This model assumes data has been ethically sourced, anonymized, and cleaned in compliance with the Kenya Data Protection Act (2019). It is positioned strictly as a decision-support tool. **The final diagnostic authority always remains with the attending clinician.**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  colorFrom: red
6
  colorTo: gray
7
  sdk: gradio
8
+ sdk_version: 4.44.1
9
  app_file: app.py
10
  pinned: false
11
+ tags:
12
+ - medical
13
+ - biology
14
+ - xai
15
+ - malaria
16
+ - sickle-cell
17
  ---
18
 
19
+ # Hemaclass AI Diagnostics: Clinical Decision Support System
20
 
21
+ An explainable ensemble-based diagnostic tool optimized for **Malaria**, **Sickle Cell Anemia (SCA)**, and **Co-infection** classification in Western Kenya.
 
22
 
23
+ ## 🔬 Model Details
24
+ - **Architecture:** Stacking Ensemble (RF, SVM, XGBoost) with a Logistic Regression Meta-Learner.
25
+ - **Explainability:** Integrated SHAP waterfall plots for local feature importance.
26
+ - **Preprocessing:** MICE Imputation, SMOTE balancing, and Z-Score Normalization.
 
 
27
 
28
+ ## 🚀 Quick Usage (Inference Code)
29
+ To use this model programmatically, ensure you have your `.pkl` artifacts in the local directory.
 
 
 
30
 
31
+ ```python
32
+ import joblib
33
+ import pandas as pd
34
+ import numpy as np
35
+
36
+ # 1. Load Artifacts
37
+ model = joblib.load('ensemble_model.pkl')
38
+ scaler = joblib.load('scaler.pkl')
39
+ imputer = joblib.load('imputer.pkl')
40
+ FEATURES = joblib.load('feature_names.pkl')
41
+ target_names = ['Negative', 'Malaria', 'SCA', 'Co-infection']
42
+
43
+ def predict_patient(data_dict):
44
+ """
45
+ Input: Dictionary of patient vitals/labs
46
+ Output: Predicted Diagnosis and Confidence
47
+ """
48
+ # Create DataFrame and align features
49
+ df = pd.DataFrame([data_dict])
50
+ for col in set(FEATURES) - set(df.columns):
51
+ df[col] = np.nan
52
+ df = df[FEATURES]
53
+
54
+ # Preprocess
55
+ X_imp = imputer.transform(df)
56
+ X_scaled = scaler.transform(X_imp)
57
+
58
+ # Inference
59
+ pred = model.predict(X_scaled)
60
+ prob = np.max(model.predict_proba(X_scaled))
61
+
62
+ return {
63
+ "Diagnosis": target_names[pred],
64
+ "Confidence": f"{prob*100:.2f}%"
65
+ }
66
+
67
+ # Example Usage:
68
+ patient_data = {'age': 25, 'hb': 10.5, 'temp': 38.5, 'malaria_rdt': 1}
69
+ print(predict_patient(patient_data))