Views
No views yet
medical_diagnosis_colab.py (each # %% Cell N section = one Colab cell)1git clone https://huggingface.co/Shadia-Sultana-Anonna/medical-diagnosis-colab
2cd medical-diagnosis-colab
3pip install -r requirements.txt
4python download_data.py # Downloads UCI Dermatology dataset
5python run_system.py # Runs complete systemmedical-diagnosis-colab/
├── modules/ # Core modules
│ ├── __init__.py
│ ├── knowledge_base.py # Knowledge Base (diseases, symptoms, rules, semantic network)
│ ├── bayesian_reasoner.py # Bayesian reasoning (Bayes' Theorem, Laplace smoothing)
│ ├── astar_search.py # A* Search algorithm for diagnosis traversal
│ ├── ml_model.py # ML models (Decision Tree + Neural Network with GridSearch)
│ ├── evaluator.py # Evaluation metrics (Accuracy, Precision, Recall, F1)
│ └── ethics_layer.py # Ethics (privacy, explainability, accountability)
├── data/ # Dataset directory
│ └── dermatology_sample.csv # Sample data (full data auto-downloaded)
├── run_system.py # Main runner script
├── download_data.py # Dataset downloader (UCI repo + fallback)
├── medical_diagnosis_colab.py # Colab notebook cells
├── requirements.txt # Python dependencies
└── README.md # This fileKnowledge Base ──→ Bayesian Reasoner ──→ A* Search
│ │ │
└──────────┬───────┘───────────────────┘
↓
ML Module (Decision Tree + Neural Network)
│
├──→ Evaluator (metrics comparison)
└──→ Ethics Layer (privacy, audit, explainability)| Module | File | Description |
|---|---|---|
| Knowledge Base | modules/knowledge_base.py | 6 diseases, 34 symptoms, IF-THEN rules, semantic network, forward chaining |
| Bayesian Reasoning | modules/bayesian_reasoner.py | P(Disease|Symptoms) via Bayes' Theorem with Laplace smoothing |
| A* Search | modules/astar_search.py | Heuristic diagnosis traversal with priority queue |
| ML Models | modules/ml_model.py | Decision Tree + Neural Network (MLP) with GridSearchCV |
| Evaluation | modules/evaluator.py | Before/after ML comparison: Accuracy, Precision, Recall, F1 |
| Ethics | modules/ethics_layer.py | SHA-256 anonymization, explainability, audit log, fairness check |
| Engine | run_system.py | Orchestrates all modules, ensemble scoring |
| Colab UI | medical_diagnosis_colab.py | Interactive symptom sliders for diagnosis |
download_data.py (tries ucimlrepo → UCI archive → local cache)| Method | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|
| Rule-Based (Bayes + Forward Chain) | ~0.75 | ~0.72 | ~0.75 | ~0.73 |
| Decision Tree (tuned) | ~0.95 | ~0.95 | ~0.95 | ~0.95 |
| Neural Network (MLP, tuned) | ~0.97 | ~0.97 | ~0.97 | ~0.97 |