File size: 1,936 Bytes
b8b74c7
 
 
 
 
 
 
 
 
7da9724
b8b74c7
 
 
 
 
5bb6e05
b8b74c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7da9724
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bcef242
7da9724
 
b8b74c7
7da9724
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

---
tags:
- random-forest
- stroke-prediction
- classification
- healthcare
license: mit
widget:
- text: "Patient details: Age 45, Hypertension 1, Avg_glucose_level 170, BMI 26"
datasets:
- stroke-prediction-dataset
---

# Stroke Prediction Model
# Date 2024-12-19

This model uses a Random Forest Classifier to predict the likelihood of a stroke based on patient details.

## Model Details
- **Algorithm**: Random Forest
- **Use Case**: Healthcare, Stroke Risk Prediction
- **Performance Metrics**:
  - **Accuracy**: 94.70%
  - **ROC-AUC Score**: 0.79
  - **Classification Report**:

    ```
              precision    recall  f1-score   support

           0       0.95      1.00      0.97       929
           1       1.00      0.02      0.04        53

    accuracy                           0.95       982
   macro avg       0.97      0.51      0.50       982
weighted avg       0.95      0.95      0.92       982
    ```

## How to Use
This model i created in google colab. Relavant libraries include:
## How to Use
This runs in google colab.

Import as per below:


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import random
from sklearn.model_selection import GridSearchCV
from sklearn.preprocessing import StandardScaler, LabelEncoder
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
from sklearn.preprocessing import MinMaxScaler

# For kaggle
import os
import zipfile

# For Hugging face
# from sklearn.externals import joblib # to save the model
from huggingface_hub import notebook_login
from huggingface_hub import Repository


Download the model and load it using `joblib
Replace input_data with your  data, e.g.  [[45, 1, 170, 26]]  # Age, Hypertension, Avg_glucose_level, BMI