criticalDanger commited on
Commit
b0ac891
1 Parent(s): a265aea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -9,25 +9,25 @@ with open('heart_disease_model.pkl', 'rb') as file:
9
  # Define the prediction function
10
  def predict_heart_disease(male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI):
11
  male = 1 if male == "Male" else 0
12
- currentSmoker = 1 if currentSmoker == "Yes" else 0
13
- BPMeds = 1 if BPMeds == "Yes" else 0
14
- prevalentStroke = 1 if prevalentStroke == "Yes" else 0
15
- prevalentHyp = 1 if prevalentHyp == "Yes" else 0
16
- diabetes = 1 if diabetes == "Yes" else 0
17
  input_data = np.array([[male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI]])
18
  prediction = model.predict(input_data)
19
  return 'Heart Disease' if prediction[0] == 1 else 'No Heart Disease'
20
 
21
  # Define the input components
22
  inputs = [
23
- gr.Textbox(label="Sex (Male/Female)"),
24
  gr.Number(label="Age"),
25
- gr.Text(label="Do you smoke? (Yes/No)"),
26
  gr.Number(label="Number of ciggerates a day"),
27
- gr.Textbox(label="Do you take BP medicines? (Yes/No)"),
28
- gr.Textbox(label="Have you had strokes previously?(Yes/No)"),
29
- gr.Textbox(label="Have you had High BP previously?(Yes/no)"),
30
- gr.Textbox(label="Do you have Diabetes?(Yes/No)"),
31
  gr.Number(value=float, label="BMI")
32
 
33
  ]
 
9
  # Define the prediction function
10
  def predict_heart_disease(male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI):
11
  male = 1 if male == "Male" else 0
12
+ currentSmoker = 1 if currentSmoker else 0
13
+ BPMeds = 1 if BPMeds else 0
14
+ prevalentStroke = 1 if prevalentStroke else 0
15
+ prevalentHyp = 1 if prevalentHyp else 0
16
+ diabetes = 1 if diabetes else 0
17
  input_data = np.array([[male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI]])
18
  prediction = model.predict(input_data)
19
  return 'Heart Disease' if prediction[0] == 1 else 'No Heart Disease'
20
 
21
  # Define the input components
22
  inputs = [
23
+ gr.Radio(choices=["Male","Female"], label="Sex"),
24
  gr.Number(label="Age"),
25
+ gr.Checkbox(label="Do you smoke?"),
26
  gr.Number(label="Number of ciggerates a day"),
27
+ gr.Checkbox(label="Do you take BP medicines?"),
28
+ gr.Checkbox(label="Have you had strokes previously?"),
29
+ gr.Checkbox(label="Have you had High BP previously?"),
30
+ gr.Checkbox(label="Do you have Diabetes?"),
31
  gr.Number(value=float, label="BMI")
32
 
33
  ]