Karthickmk/neuro-symbolic-medical-ai
0
Neuro-Symbolic AI for Explainable Medical Image Diagnosis
A full end-to-end prototype system implementing neuro-symbolic AI for explainable medical image diagnosis across chest X-ray and dermoscopy modalities, as described in the accompanying research report.
Architecture
The system combines:
- Neural component — Random Forest + MLP ensemble trained on HOG, colour, and statistical features
- Symbolic component — Domain rule engine encoding radiology and dermoscopy clinical concepts
- Explainability module — Feature-importance saliency overlays, concept radar charts, confusion matrices
- Database layer — SQLite schema linking datasets → images → concepts → predictions → explanations
- Web interface — Flask dashboard for pipeline control, prediction inspection, and database browsing
Requirements
Python 3.10+ is required.
pip install -r requirements.txtQuick Start
1. Start the web server (recommended)
python run.pyThe browser opens automatically at http://127.0.0.1:5000.
Then click "Run Pipeline" on the Pipeline page to generate synthetic data, train both models, run inference, and populate the database. The whole process takes 2–4 minutes.
2. Run pipeline first, then server
python run.py --run-pipeline3. Command-line options
--host HOST Bind host (default: 0.0.0.0)
--port PORT Bind port (default: 5000)
--no-browser Skip auto-opening the browser
--run-pipeline Execute the full pipeline before starting FlaskWeb Interface Pages
Project Structure
neuro_symbolic_medical_ai/
├── run.py # Entry point — starts Flask server
├── config.py # Global configuration
├── requirements.txt
├── pipeline/
│ ├── database.py # SQLite schema and CRUD
│ ├── data_generator.py # Synthetic smoke-test image generation
│ ├── feature_extractor.py # HOG, colour, statistical features + concepts
│ ├── model.py # RF + MLP ensemble classifier
│ ├── symbolic_engine.py # Rule-based clinical reasoning
│ ├── explainer.py # Saliency overlays and visualisation
│ └── pipeline_runner.py # Orchestrates the full pipeline
├── web/
│ ├── app.py # Flask routes
│ ├── templates/ # Jinja2 HTML templates
│ └── static/ # CSS and JS
├── data/ # Auto-generated synthetic images
└── outputs/
├── models/ # Trained classifier pickles
├── plots/ # Confusion matrices, performance charts
├── overlays/ # Per-image saliency overlays
└── reports/ # JSON pipeline summary reportDatasets (Synthetic Smoke-Test)
The prototype generates 460 synthetic images proportionally representing four public datasets:
Notes
- All performance metrics (accuracy, F1) are on synthetic data and serve only to validate the software pipeline, not clinical utility.
- To use real datasets, replace the contents of
data/with actual images and re-run the pipeline. - The symbolic agreement rate on synthetic data is lower than ideal (~29%) because synthetic images do not faithfully reproduce the real-world correlation between visual features and clinical labels.
