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.
data/stroke_risk_prediction_dataset.csv.backend/ml/analyze_dataset.py; it prints the requested checks and regenerates reports/dataset_analysis.md.backend/ml/data_quality.py; it updates backend/ml/feature_config.json and reports/data_quality_and_leakage.md.backend/ml/prepare_data.py at data/processed/stroke_risk_prepared.csv.backend/ml/exploratory_analysis.py; it writes figures to images/eda/ and a report to reports/exploratory_data_analysis.md.backend/ml/PREPROCESSING.md.backend/ml/IMBALANCE.md.backend/ml/train_models.py; it uses train and validation only and leaves the final test locked.backend/ml/TUNING.md.backend/app/services/SHAP.md and exposed through /explain and /explanations API routes.backend/app/API.md.From the workspace root, run:
python backend/ml/analyze_dataset.py
An alternate CSV or report destination can be supplied with --csv and --report.
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/.
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.
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.
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.
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.
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.
This system is for educational experimentation only. Its outputs are not medical diagnoses or a substitute for professional medical advice.