# dummycodertech/xai-xgboost-heart_stroke architecture

> Architecture diagram of the GitHub repository dummycodertech/xai-xgboost-heart_stroke, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dummycodertech/xai-xgboost-heart_stroke
- Repository: https://github.com/dummycodertech/xai-xgboost-heart_stroke

## Overview

Clinical Stroke Predictor is a Streamlit triage application backed by an XGBoost model trained for imbalanced stroke data. The main workflow runs from patient-entered features through preprocessing, probability scoring and a configurable clinical threshold to a risk result and local SHAP explanation. The app also presents global SHAP insights, LIME explanations for selected edge cases, and model metrics. Training and explanation artifacts are prepared by separate scripts. Relationships are shown where excerpts or README statements support them; unsampled implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py) (Streamlit triage app), [`data`](https://github.com/dummycodertech/xai-xgboost-heart_stroke/tree/main/data) (Processed splits), [`models/xgboost_model.pkl`](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/xgboost_model.pkl) (Trained model), [`data_loader.py`](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/data_loader.py) (Preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_raw_data["Stroke dataset"]
  node_loader["Preprocessing<br/>[data_loader.py]"]
  node_processed["Processed splits"]
  node_preprocessor["Fitted preprocessor<br/>[preprocessor.pkl]"]
end

subgraph group_training["Model training"]
  node_trainer["XGBoost training<br/>[model_trainer.py]"]
  node_model["Trained model<br/>[xgboost_model.pkl]"]
  node_metadata["Evaluation metrics"]
end

subgraph group_analysis["Model analysis"]
  node_shap_setup["SHAP analysis<br/>[shap_explainer.py]"]
  node_shap_artifacts["SHAP artifacts"]
  node_edge_detector["Edge-case detection<br/>[edgecasedec.py]"]
  node_edge_cases["Edge-case records<br/>[edge_cases.json]"]
  node_lime_setup["LIME setup<br/>[lime_expl.py]"]
  node_lime_artifact["LIME explainer<br/>[lime_explainer.pkl]"]
end

subgraph group_app["Triage application"]
  node_app["Streamlit triage app<br/>[app.py]"]
  node_risk_result["Risk and explanations<br/>[app.py]"]
  node_dashboard["Insights and metrics<br/>[app.py]"]
end

node_patient(("Patient or user"))

node_patient -->|"enters features"| node_app
node_raw_data -->|"loads data"| node_loader
node_loader -->|"writes splits"| node_processed
node_loader -->|"saves fitted transform"| node_preprocessor
node_processed -->|"loads splits"| node_trainer
node_trainer -->|"saves model"| node_model
node_trainer -->|"saves metrics"| node_metadata
node_model -->|"loads model"| node_shap_setup
node_processed -->|"loads test split"| node_shap_setup
node_shap_setup -->|"saves values"| node_shap_artifacts
node_model -->|"loads model"| node_edge_detector
node_processed -->|"loads test split"| node_edge_detector
node_edge_detector -->|"saves cases"| node_edge_cases
node_processed -->|"loads training split"| node_lime_setup
node_lime_setup -->|"saves explainer"| node_lime_artifact
node_app -->|"loads transform"| node_preprocessor
node_app -->|"loads model"| node_model
node_app -->|"loads metrics"| node_metadata
node_app -->|"loads test split"| node_processed
node_app -->|"loads global values"| node_shap_artifacts
node_app -->|"loads explainer"| node_lime_artifact
node_app -->|"loads cases"| node_edge_cases
node_app -->|"renders prediction"| node_risk_result
node_app -->|"renders insights"| node_dashboard
node_preprocessor -->|"transforms input"| node_risk_result
node_model -->|"scores features"| node_risk_result
node_shap_artifacts -->|"drives global plots"| node_dashboard
node_metadata -->|"supplies metrics"| node_dashboard
node_edge_cases -->|"selects cases"| node_dashboard
node_lime_artifact -->|"explains selected case"| node_dashboard
node_risk_result -->|"renders local SHAP"| node_app

click node_raw_data "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/data/healthcare-dataset-stroke-data.csv"
click node_loader "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/data_loader.py"
click node_processed "https://github.com/dummycodertech/xai-xgboost-heart_stroke/tree/main/data"
click node_trainer "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/model_trainer.py"
click node_model "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/xgboost_model.pkl"
click node_metadata "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/training_metadata.json"
click node_shap_setup "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/shap_explainer.py"
click node_shap_artifacts "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/shap_values_test.pkl"
click node_edge_detector "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/edgecasedec.py"
click node_edge_cases "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/edge_cases.json"
click node_lime_setup "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/lime_expl.py"
click node_lime_artifact "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/lime_explainer.pkl"
click node_app "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py"
click node_preprocessor "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/preprocessor.pkl"
click node_risk_result "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py"
click node_dashboard "https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raw_data,node_loader,node_processed,node_preprocessor,node_patient toneBlue
class node_trainer,node_model,node_metadata toneAmber
class node_shap_setup,node_shap_artifacts,node_edge_detector,node_edge_cases,node_lime_setup,node_lime_artifact toneMint
class node_app,node_risk_result,node_dashboard toneRose
```

## Components

### Data preparation

- [Stroke dataset](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/data/healthcare-dataset-stroke-data.csv): `data/healthcare-dataset-stroke-data.csv`
- [Preprocessing](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/data_loader.py): `data_loader.py`
- [Processed splits](https://github.com/dummycodertech/xai-xgboost-heart_stroke/tree/main/data): `data`
- [Fitted preprocessor](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/preprocessor.pkl): `models/preprocessor.pkl`

### Model training

- [XGBoost training](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/model_trainer.py): `model_trainer.py`
- [Trained model](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/xgboost_model.pkl): `models/xgboost_model.pkl`
- [Evaluation metrics](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/training_metadata.json): `models/training_metadata.json`

### Model analysis

- [SHAP analysis](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/shap_explainer.py): `shap_explainer.py`
- [SHAP artifacts](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/shap_values_test.pkl): `models/shap_values_test.pkl`
- [Edge-case detection](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/edgecasedec.py): `edgecasedec.py`
- [Edge-case records](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/edge_cases.json): `models/edge_cases.json`
- [LIME setup](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/lime_expl.py): `lime_expl.py`
- [LIME explainer](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/models/lime_explainer.pkl): `models/lime_explainer.pkl`

### Triage application

- [Streamlit triage app](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py): `app.py`
- [Risk and explanations](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py): `app.py`
- [Insights and metrics](https://github.com/dummycodertech/xai-xgboost-heart_stroke/blob/main/app.py): `app.py`

### Other components

- **Patient or user**

## Connections

- Patient or user → Streamlit triage app: enters features (evidence: `app.py`)
- Stroke dataset → Preprocessing: loads data (evidence: `data_loader.py`)
- Preprocessing → Processed splits: writes splits (evidence: `data_loader.py`)
- Preprocessing → Fitted preprocessor: saves fitted transform (evidence: `data_loader.py`)
- Processed splits → XGBoost training: loads splits (evidence: `model_trainer.py`)
- XGBoost training → Trained model: saves model (evidence: `model_trainer.py`)
- XGBoost training → Evaluation metrics: saves metrics (evidence: `model_trainer.py`)
- Trained model → SHAP analysis: loads model (evidence: `shap_explainer.py`)
- Processed splits → SHAP analysis: loads test split (evidence: `shap_explainer.py`)
- SHAP analysis → SHAP artifacts: saves values (evidence: `shap_explainer.py`)
- Trained model → Edge-case detection: loads model (evidence: `edgecasedec.py`)
- Processed splits → Edge-case detection: loads test split (evidence: `edgecasedec.py`)
- Edge-case detection → Edge-case records: saves cases (evidence: `edgecasedec.py`)
- Processed splits → LIME setup: loads training split (evidence: `lime_expl.py`)
- LIME setup → LIME explainer: saves explainer (evidence: `lime_expl.py`)
- Streamlit triage app → Fitted preprocessor: loads transform (evidence: `app.py`)
- Streamlit triage app → Trained model: loads model (evidence: `app.py`)
- Streamlit triage app → Evaluation metrics: loads metrics (evidence: `app.py`)
- Streamlit triage app → Processed splits: loads test split (evidence: `app.py`)
- Streamlit triage app → SHAP artifacts: loads global values (evidence: `app.py`)
- Streamlit triage app → LIME explainer: loads explainer (evidence: `app.py`)
- Streamlit triage app → Edge-case records: loads cases (evidence: `app.py`)
- Streamlit triage app → Risk and explanations: renders prediction (evidence: `app.py`)
- Streamlit triage app → Insights and metrics: renders insights (evidence: `app.py`)
- Fitted preprocessor → Risk and explanations: transforms input (evidence: `app.py`)
- Trained model → Risk and explanations: scores features (evidence: `app.py`)
- SHAP artifacts → Insights and metrics: drives global plots (evidence: `app.py`)
- Evaluation metrics → Insights and metrics: supplies metrics (evidence: `app.py`)
- Edge-case records → Insights and metrics: selects cases (evidence: `app.py`)
- LIME explainer → Insights and metrics: explains selected case (evidence: `app.py`)
- Risk and explanations → Streamlit triage app: renders local SHAP (evidence: `app.py`)
