hackerbyhobby commited on
Commit
fcf0bca
·
unverified ·
1 Parent(s): 6ed3230
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -27,14 +27,28 @@ with gr.Blocks() as app:
27
  gr.Markdown("# Health Risk Prediction App")
28
  gr.Markdown("### Input the feature values below to predict health risks.")
29
 
30
- input_components = []
31
- for feature in ['State', 'Sex', 'GeneralHealth', 'PhysicalHealthDays', 'MentalHealthDays', 'LastCheckupTime', 'PhysicalActivities', 'SleepHours', 'HadStroke', 'HadArthritis', 'HadDiabetes', 'SmokerStatus', 'ECigaretteUsage', 'RaceEthnicityCategory', 'AgeCategory', 'HeightInMeters', 'WeightInKilograms', 'BMI', 'AlcoholDrinkers', 'HighRiskLastYear']:
32
- if "Days" in feature or "Hours" in feature or "BMI" in feature:
33
- input_components.append(gr.Slider(0, 100, step=1, label=feature))
34
- elif "Sex" in feature:
35
- input_components.append(gr.Radio(["Male", "Female"], label=feature))
36
- else:
37
- input_components.append(gr.Textbox(label=feature))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  predict_button = gr.Button("Predict")
40
  output = gr.Textbox(label="Prediction Result")
@@ -42,7 +56,7 @@ with gr.Blocks() as app:
42
  # Connect prediction logic
43
  predict_button.click(
44
  fn=predict_with_model,
45
- inputs=input_components,
46
  outputs=output,
47
  )
48
 
 
27
  gr.Markdown("# Health Risk Prediction App")
28
  gr.Markdown("### Input the feature values below to predict health risks.")
29
 
30
+ inputs = [
31
+ gr.Dropdown(["Alabama", "Alaska", "Arizona", "Arkansas", "California"], label="State"), # Example states
32
+ gr.Radio(["Male", "Female"], label="Sex"),
33
+ gr.Radio(["Excellent", "Very Good", "Good", "Fair", "Poor"], label="GeneralHealth"),
34
+ gr.Slider(0, 30, step=1, label="PhysicalHealthDays"),
35
+ gr.Slider(0, 30, step=1, label="MentalHealthDays"),
36
+ gr.Radio(["Within last year", "1-2 years ago", "3-5 years ago", "5+ years ago"], label="LastCheckupTime"),
37
+ gr.Radio(["Yes", "No"], label="PhysicalActivities"),
38
+ gr.Slider(0, 24, step=1, label="SleepHours"),
39
+ gr.Radio(["Yes", "No"], label="HadStroke"),
40
+ gr.Radio(["Yes", "No"], label="HadArthritis"),
41
+ gr.Radio(["Yes", "No"], label="HadDiabetes"),
42
+ gr.Radio(["Smoker", "Non-Smoker"], label="SmokerStatus"),
43
+ gr.Radio(["Yes", "No"], label="ECigaretteUsage"),
44
+ gr.Dropdown(["White", "Black", "Asian", "Hispanic", "Other"], label="RaceEthnicityCategory"),
45
+ gr.Dropdown(["18-24", "25-34", "35-44", "45-54", "55-64", "65+"], label="AgeCategory"),
46
+ gr.Slider(1.0, 2.5, step=0.01, label="HeightInMeters"),
47
+ gr.Slider(30, 200, step=1, label="WeightInKilograms"),
48
+ gr.Slider(10, 50, step=0.1, label="BMI"),
49
+ gr.Radio(["Yes", "No"], label="AlcoholDrinkers"),
50
+ gr.Radio(["Yes", "No"], label="HighRiskLastYear"),
51
+ ]
52
 
53
  predict_button = gr.Button("Predict")
54
  output = gr.Textbox(label="Prediction Result")
 
56
  # Connect prediction logic
57
  predict_button.click(
58
  fn=predict_with_model,
59
+ inputs=inputs,
60
  outputs=output,
61
  )
62