Abdullah1211 commited on
Commit
0e07b80
·
verified ·
1 Parent(s): 83cf462

Upload 11 files

Browse files
Files changed (4) hide show
  1. README.md +82 -38
  2. sample_submission.csv +0 -0
  3. test.csv +0 -0
  4. train.csv +0 -0
README.md CHANGED
@@ -8,62 +8,106 @@ app_file: app.py
8
  pinned: false
9
  ---
10
 
11
- # Stroke Prediction Model
12
 
13
- This model predicts the risk of stroke based on demographic and health-related features.
14
 
15
- ## Model Details
16
 
17
- - **Model Type**: Random Forest Classifier
18
- - **Training Data**: Healthcare data including age, gender, various diseases, and lifestyle factors
19
- - **Features**: Age, gender, hypertension, heart disease, marital status, work type, residence type, glucose level, BMI, smoking status
20
- - **Output**: Probability of stroke risk (0-1) and risk category
21
 
22
- ## Usage
23
 
24
- You can use this model through the Hugging Face Inference API:
25
 
26
- ```python
27
- import requests
28
 
29
- API_URL = "https://abdullah1211-ml-stroke.hf.space"
30
- headers = {"Content-Type": "application/json"}
31
 
32
- def query(payload):
33
- response = requests.post(API_URL, headers=headers, json=payload)
34
- return response.json()
35
-
36
- data = {
37
- "gender": "Male",
38
- "age": 67,
39
- "hypertension": 1,
40
- "heart_disease": 0,
41
- "ever_married": "Yes",
42
- "work_type": "Private",
43
- "Residence_type": "Urban",
44
- "avg_glucose_level": 228.69,
45
- "bmi": 36.6,
46
- "smoking_status": "formerly smoked"
47
  }
48
-
49
- output = query(data)
50
- print(output)
51
  ```
52
 
53
- ## Response Format
54
 
55
  ```json
56
  {
57
  "probability": 0.72,
58
  "prediction": "High Risk",
59
- "stroke_prediction": 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
  ```
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  ## Risk Categories
64
 
65
- - Very Low Risk: probability < 0.2
66
- - Low Risk: probability between 0.2 and 0.4
67
- - Moderate Risk: probability between 0.4 and 0.6
68
- - High Risk: probability between 0.6 and 0.8
69
- - Very High Risk: probability > 0.8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  pinned: false
9
  ---
10
 
11
+ # Stroke Risk Prediction Model
12
 
13
+ This Hugging Face Space hosts a machine learning model for stroke risk prediction based on various health and demographic factors.
14
 
15
+ ## Model Overview
16
 
17
+ - **Type**: Random Forest Classifier
18
+ - **Target**: Binary classification (stroke risk)
19
+ - **Output**: Probability of stroke risk + risk category
20
+ - **Features**: Age, gender, hypertension, heart disease, BMI, glucose levels, and more
21
 
22
+ ## API Endpoints
23
 
24
+ ### POST `/api/predict`
25
 
26
+ Predicts stroke risk based on patient health data.
 
27
 
28
+ #### Request Format
 
29
 
30
+ ```json
31
+ {
32
+ "gender": "Male",
33
+ "age": 67,
34
+ "hypertension": 1,
35
+ "heart_disease": 0,
36
+ "ever_married": "Yes",
37
+ "work_type": "Private",
38
+ "Residence_type": "Urban",
39
+ "avg_glucose_level": 228.69,
40
+ "bmi": 36.6,
41
+ "smoking_status": "formerly smoked"
 
 
 
42
  }
 
 
 
43
  ```
44
 
45
+ #### Response Format
46
 
47
  ```json
48
  {
49
  "probability": 0.72,
50
  "prediction": "High Risk",
51
+ "stroke_prediction": 1,
52
+ "risk_factors": [
53
+ "Advanced Age (>65)",
54
+ "Very High Blood Glucose (>200)",
55
+ "Obesity (BMI > 30)",
56
+ "Former Smoker"
57
+ ],
58
+ "important_features": [
59
+ {"feature": "avg_glucose_level", "importance": 0.31},
60
+ {"feature": "age", "importance": 0.28},
61
+ {"feature": "bmi", "importance": 0.15}
62
+ ],
63
+ "execution_time_ms": 50,
64
+ "using_model": true,
65
+ "model_version": "1.0"
66
  }
67
  ```
68
 
69
+ ### GET `/`
70
+
71
+ Returns information about the model and API usage.
72
+
73
+ ## Parameter Details
74
+
75
+ | Parameter | Description | Type | Values |
76
+ |-----------|-------------|------|--------|
77
+ | gender | Gender of the patient | String | "Male", "Female", "Other" |
78
+ | age | Age in years | Number | 0-120 |
79
+ | hypertension | Whether patient has hypertension | Number | 0 (No), 1 (Yes) |
80
+ | heart_disease | Whether patient has heart disease | Number | 0 (No), 1 (Yes) |
81
+ | ever_married | Whether patient has ever been married | String | "Yes", "No" |
82
+ | work_type | Type of work/employment | String | "Private", "Self-employed", "Govt_job", "children", "Never_worked" |
83
+ | Residence_type | Type of residence | String | "Urban", "Rural" |
84
+ | avg_glucose_level | Average glucose level in blood (mg/dL) | Number | 50-300+ |
85
+ | bmi | Body Mass Index | Number | 10-50+ |
86
+ | smoking_status | Smoking status of patient | String | "never smoked", "formerly smoked", "smokes", "Unknown" |
87
+
88
  ## Risk Categories
89
 
90
+ - **Very Low Risk**: < 10% probability
91
+ - **Low Risk**: 10-20% probability
92
+ - **Moderate Risk**: 20-40% probability
93
+ - **High Risk**: 40-60% probability
94
+ - **Very High Risk**: > 60% probability
95
+
96
+ ## Model Training
97
+
98
+ This model was trained on a dataset of over 5,000 patients with various health metrics and stroke outcomes. It identifies key risk factors like:
99
+
100
+ - Age
101
+ - High blood pressure
102
+ - Heart disease
103
+ - Glucose levels
104
+ - BMI
105
+ - Smoking status
106
+
107
+ ## Integration with BrainWise App
108
+
109
+ This model serves as the backend for the BrainWise app's stroke risk calculator, providing users with risk assessments based on their health metrics.
110
+
111
+ ## Disclaimer
112
+
113
+ This model is for informational purposes only and should not replace professional medical advice. Always consult with healthcare providers for medical decisions.
sample_submission.csv ADDED
The diff for this file is too large to render. See raw diff
 
test.csv ADDED
The diff for this file is too large to render. See raw diff
 
train.csv ADDED
The diff for this file is too large to render. See raw diff