Commit
·
c7a8697
1
Parent(s):
ee17659
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,19 +12,21 @@ loaded_model = pickle.load(open("heart_xgb.pkl", 'rb'))
|
|
| 12 |
# Setup SHAP
|
| 13 |
explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
|
| 14 |
|
| 15 |
-
gender = {"Female":
|
| 16 |
-
chest = {"Typical angina":
|
| 17 |
choice = {"True":1, "False":0}
|
| 18 |
-
rest = {"Probable or Definite Left Ventricular Hypertrophy by Estes' Criteria":
|
| 19 |
ex = {"Yes":1, "No":0}
|
| 20 |
-
sl = {"Upsloping":
|
| 21 |
-
th = {"Reversible Defect":
|
| 22 |
|
| 23 |
# Create the main function for server
|
| 24 |
-
def main_func(age, sex, cp, trtbps, chol, fbs, restecg, thalachh,
|
| 25 |
-
new_row = pd.DataFrame.from_dict({'age':age,'sex':
|
| 26 |
-
'cp':
|
| 27 |
-
'
|
|
|
|
|
|
|
| 28 |
|
| 29 |
prob = loaded_model.predict_proba(new_row)
|
| 30 |
|
|
@@ -76,7 +78,7 @@ with gr.Blocks(title=title) as demo:
|
|
| 76 |
with gr.Column():
|
| 77 |
age = gr.Slider(label="Age", minimum=0, maximum=100, value=40, step=1)
|
| 78 |
sex = gr.Radio(label="Sex", choices =["Female","Male"])
|
| 79 |
-
cp = gr.
|
| 80 |
trtbps = gr.Slider(label="Resting Blood Pressure (in mm Hg)", minimum=90, maximum=200, value=90, step=1)
|
| 81 |
chol = gr.Slider(label="Cholestoral in mg/dl", minimum=120, maximum=570, value=120, step=1)
|
| 82 |
fbs = gr.Radio(label="Fasting Blood Sugar", choices = ["True", "False"])
|
|
|
|
| 12 |
# Setup SHAP
|
| 13 |
explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
|
| 14 |
|
| 15 |
+
gender = {"Female":1,"Male":0}
|
| 16 |
+
chest = {"Typical angina":0,"Atypical angina":1,"Non-anginal pain":2,"Asymptomatic":3}
|
| 17 |
choice = {"True":1, "False":0}
|
| 18 |
+
rest = {"Probable or Definite Left Ventricular Hypertrophy by Estes' Criteria":0, "Having ST - T Wave Abnormality":1,"Normal Value":2}
|
| 19 |
ex = {"Yes":1, "No":0}
|
| 20 |
+
sl = {"Upsloping":0, "Flat":1,"Downsloping":2}
|
| 21 |
+
th = {"Reversible Defect":0, "Normal Blood Flow":1, "Fixed Defect":2}
|
| 22 |
|
| 23 |
# Create the main function for server
|
| 24 |
+
def main_func(age, sex, cp, trtbps, chol, fbs, restecg, thalachh,exng,oldpeak,slp,caa,thall):
|
| 25 |
+
new_row = pd.DataFrame.from_dict({'age':age,'sex':sex,
|
| 26 |
+
'cp':cp,'trtbps':trtbps,'chol':chol,
|
| 27 |
+
'fbs':fbs, 'restecg':restecg,'thalachh':thalachh,'exng':exng,
|
| 28 |
+
'oldpeak':oldpeak,'slp':slp,'caa':caa,'thall':thall},
|
| 29 |
+
orient = 'index').transpose()
|
| 30 |
|
| 31 |
prob = loaded_model.predict_proba(new_row)
|
| 32 |
|
|
|
|
| 78 |
with gr.Column():
|
| 79 |
age = gr.Slider(label="Age", minimum=0, maximum=100, value=40, step=1)
|
| 80 |
sex = gr.Radio(label="Sex", choices =["Female","Male"])
|
| 81 |
+
cp = gr.Select(label="Chest Pain Type", choices = ["Typical angina", "Atypical angina", "Non-anginal pain", "Asymptomatic"])
|
| 82 |
trtbps = gr.Slider(label="Resting Blood Pressure (in mm Hg)", minimum=90, maximum=200, value=90, step=1)
|
| 83 |
chol = gr.Slider(label="Cholestoral in mg/dl", minimum=120, maximum=570, value=120, step=1)
|
| 84 |
fbs = gr.Radio(label="Fasting Blood Sugar", choices = ["True", "False"])
|