wszhang1021 commited on
Commit
d0f8e5c
·
1 Parent(s): c2dcbdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -13,19 +13,19 @@ loaded_model = pickle.load(open("heart_xgb.pkl", 'rb'))
13
  explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
14
 
15
  gender = {"Female":1,"Male":0}
16
- cp = {"Typical angina":0,"Atypical angina":1,"Non-anginal pain":2,"Asymptomatic":3}
17
  bloodsuguar = {"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':gender[sex],
26
- 'cp':cp[cp],'trtbps':trtbps,'chol':chol,
27
  'fbs':bloodsuguar[fbs], 'restecg':rest[restecg],'thalachh':thalachh,'exng':ex[exng],
28
- 'oldpeak':oldpeak,'slp':sl[slp],'caa':caa,'thall':thl[thall]},
29
  orient = 'index').transpose()
30
 
31
  prob = loaded_model.predict_proba(new_row)
 
13
  explainer = shap.Explainer(loaded_model) # PLEASE DO NOT CHANGE THIS.
14
 
15
  gender = {"Female":1,"Male":0}
16
+ chestpain = {"Typical angina":0,"Atypical angina":1,"Non-anginal pain":2,"Asymptomatic":3}
17
  bloodsuguar = {"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
+ slope = {"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':gender[sex],
26
+ 'cp':chestpain[cp],'trtbps':trtbps,'chol':chol,
27
  'fbs':bloodsuguar[fbs], 'restecg':rest[restecg],'thalachh':thalachh,'exng':ex[exng],
28
+ 'oldpeak':oldpeak,'slp':slope[slp],'caa':caa,'thall':thl[thall]},
29
  orient = 'index').transpose()
30
 
31
  prob = loaded_model.predict_proba(new_row)