Explainable-Stroke-Risk-AI

Explainable AI-Based Stroke Risk Assessment System

An educational project scaffold for exploring stroke-risk classification and model explainability. It is not a medical device and must not be used to diagnose, treat, or guide care.

Current status

Dataset analysis

From the workspace root, run:

python backend/ml/analyze_dataset.py

An alternate CSV or report destination can be supplied with --csv and --report.

Data quality and EDA

From the workspace root, run the checks and prepare the separate model-input copy:

python backend/ml/data_quality.py
python backend/ml/prepare_data.py
python backend/ml/exploratory_analysis.py

The EDA runner uses the persisted feature configuration and prepared dataset. It does not train a model; figures are saved under images/eda/.

Stratified splits and imbalance

python backend/ml/split_data.py
python backend/ml/class_imbalance.py

These commands create train, validation, and locked final-test partitions, then compare training-only balanced weights and random oversampling. The test partition is not read by the imbalance analysis.

Baseline model evaluation

python backend/ml/train_models.py

This trains the four baseline candidates on the training split, evaluates them on validation, and saves metrics, curves, and candidate pipelines. It does not access the locked test split or tune hyperparameters.

Hyperparameter tuning and final evaluation

python -m backend.ml.tune_models

This uses stratified cross-validation on training data, validation-based model selection, then evaluates the selected pipeline once on the locked test split and saves the final artifacts.

Backend

Create and activate a Python environment, then install backend dependencies:

python -m venv backend/.venv
backend/.venv/Scripts/Activate.ps1
python -m pip install -r backend/requirements.txt

Start the API from the backend directory:

python -m uvicorn app.main:app --reload

The health check is at http://127.0.0.1:8000/health and the generated API documentation is at http://127.0.0.1:8000/docs.

Frontend

In another terminal, from the workspace root:

Copy-Item frontend/.env.example frontend/.env.local
Set-Location frontend
npm install
npm run dev

Open http://localhost:5173. Set VITE_API_BASE_URL in frontend/.env.local if the API runs at another origin. The backend CORS allow-list is configured with FRONTEND_ORIGINS.

Safety

This system is for educational experimentation only. Its outputs are not medical diagnoses or a substitute for professional medical advice.