MotavalD/Stroke_Prediction
0
๐ซ Stroke Risk Prediction API
A machine learning API that predicts stroke risk from patient health data. Built with FastAPI, Scikit-learn, and Docker โ deployed as a production-ready REST endpoint.
What it does
Takes patient health indicators as input and returns a binary stroke risk prediction (0 = low risk, 1 = high risk). The model was trained on a healthcare stroke dataset with preprocessing, feature engineering, and class-imbalance handling.
Tech stack
API usage
Endpoint: POST /predict
Request body (JSON):
{
"age": 67.0,
"hypertension": 0,
"heart_disease": 1,
"avg_glucose_level": 228.69,
"bmi": 36.6,
"gender_Male": 1,
"gender_Other": 0,
"ever_married_Yes": 1,
"work_type_Never_worked": 0,
"work_type_Private": 1,
"work_type_Self_employed": 0,
"work_type_children": 0,
"Residence_type_Urban": 0,
"smoking_status_formerly_smoked": 1,
"smoking_status_never_smoked": 0,
"smoking_status_smokes": 0
}Response:
{
"prediction": 1
}1 = high stroke risk, 0 = low stroke risk
Input features explained
Run locally
# Clone the space
git clone https://huggingface.co/spaces/MotavalD/Stroke_Prediction
# Build and run with Docker
docker build -t stroke-api .
docker run -p 7860:7860 stroke-api
# Test the API
curl -X POST http://localhost:7860/predict \
-H "Content-Type: application/json" \
-d '{"age": 67, "hypertension": 0, "heart_disease": 1, ...}'GitHub
Full source code and model training notebook available at: ๐ github.com/dhruv-motaval
Built by [Dhruv Motaval](https://www.linkedin.com/in/dhruv-motaval/) โ B.Tech AI, Parul University
