File size: 2,065 Bytes
221a3ee
7f42b7f
2ae0259
8ff934a
7fcf9cc
8ff934a
2ae0259
7559250
 
 
 
 
78d7ec0
7ffa06d
2accb7d
ed70faa
58fa5a3
cd84d16
221a3ee
 
 
 
 
 
 
 
 
 
 
 
 
0fde028
c5d438e
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
import gradio as gr
import pycaret
from pycaret.classification import *
import pandas as pd
import category_encoders as ce
healthcare_stroke_data = pd.read_csv("healthcare-dataset-stroke-data.csv")

encoder= ce.OrdinalEncoder(cols=['gender'],return_df=True, mapping=[{'col':'gender', 'mapping':{0: 1, 1: 2,'Other': 3}}])
healthcare_stroke_data['gender'] = encoder.fit_transform(healthcare_stroke_data['gender'])
encoder= ce.OrdinalEncoder(cols=['work_type'],return_df=True, mapping=[{'col':'work_type', 'mapping':{0: 1, 1: 2, 'children': 3, '2': 4, 'Never_worked': 5}}])
healthcare_stroke_data['work_type'] = encoder.fit_transform(healthcare_stroke_data['work_type'])

s = setup(data = healthcare_stroke_data, target = 'stroke', fix_imbalance = True, session_id=123)

best = compare_models()
compare_model_results = pull()
            
model = gr.inputs.Dropdown(list(compare_model_results['Model']),label="Model")
gender = gr.inputs.Dropdown(choices=["Male", "Female"],label = 'gender')
age = gr.inputs.Slider(minimum=1, maximum=100, default=data['age'].mean(), label = 'age')
hypertension = gr.inputs.Dropdown(choices=["1", "0"],label = 'hypertension')
heart_disease = gr.inputs.Dropdown(choices=["1", "0"],label ='heart_disease')
ever_married = gr.inputs.Dropdown(choices=["Yes", "No"], label ='ever_married')
work_type = gr.inputs.Dropdown(choices=["children", "Govt_job","Never_worked","Private","Self-employed"],label = 'work_type')
Residence_type = gr.inputs.Dropdown(choices=["Urban", "Rural"],label = 'Residence_type')
avg_glucose_level =	gr.inputs.Slider(minimum=-55, maximum=300, default=data['avg_glucose_level'].mean(), label = 'avg_glucose_level')
bmi = gr.inputs.Slider(minimum=-10, maximum=100, default=data['bmi'].mean(), label = 'bmi')
smoking_status = gr.inputs.Dropdown(choices=["Unknown", "smokes","never_smoked", "formerly_smoked"], label ='smoking_status')

gr.Interface(predict,[model, gender, age, hypertension, heart_disease, ever_married, work_type, Residence_type, avg_glucose_level, bmi, smoking_status], "label",live=True).launch()