saad177 commited on
Commit
221622c
1 Parent(s): 339157b

add checkbox

Browse files
Files changed (1) hide show
  1. app.py +9 -61
app.py CHANGED
@@ -27,53 +27,6 @@ feature_view = fs.get_or_create_feature_view(
27
  )
28
  diabetes_df = pd.DataFrame(diabetes_fg.read())
29
 
30
-
31
- # def plot_reference(age, bmi, hba1c_level, blood_glucose_level):
32
- # mean_for_age = diabetes_df[
33
- # (diabetes_df["diabetes"] == 0) & (diabetes_df["age"] == age)
34
- # ].mean()
35
- # print("your bmi is:", bmi, "the mean for ur age is :", mean_for_age["bmi"])
36
- # categories = ["Age", "BMI", "HbA1c", "Blood Level"]
37
- # fig, ax = plt.subplots()
38
- # bar_width = 0.35
39
- # indices = np.arange(len(categories))
40
- # ax.bar(
41
- # indices,
42
- # [mean_for_age.bmi, mean_for_age.hba1c_level, mean_for_age.blood_glucose_level],
43
- # bar_width,
44
- # label="Reference",
45
- # color="b",
46
- # alpha=0.7,
47
- # )
48
- # ax.bar(
49
- # indices + bar_width,
50
- # [bmi, hba1c_level, blood_glucose_level],
51
- # bar_width,
52
- # label="User",
53
- # color="r",
54
- # alpha=0.7,
55
- # )
56
-
57
- # ax.set_xlabel("Variables")
58
- # ax.set_ylabel("Values")
59
- # ax.set_title("Comparison of Reference and User Values")
60
- # ax.set_xticks(indices + bar_width / 2)
61
- # ax.set_xticklabels(categories)
62
-
63
-
64
- # def diabetes(age, bmi, hba1c_level, blood_glucose_level):
65
- # print("Calling diabetes function")
66
- # df = pd.DataFrame(
67
- # [[age, bmi, hba1c_level, blood_glucose_level]],
68
- # columns=["age", "bmi", "hba1c_level", "blood_glucose_level"],
69
- # )
70
- # print("Predicting")
71
- # print(df)
72
- # res = model.predict(df)
73
- # print(res)
74
- # return res
75
-
76
-
77
  with gr.Blocks() as demo:
78
  with gr.Row():
79
  gr.HTML(value="<h1 style='text-align: center;'>Diabetes prediction</h1>")
@@ -87,6 +40,13 @@ with gr.Blocks() as demo:
87
  blood_glucose_input = gr.Slider(
88
  80, 300, label="blood_glucose_level", info="Blood Glucose Level"
89
  )
 
 
 
 
 
 
 
90
  btn = gr.Button("Submit")
91
  with gr.Column():
92
  output = gr.Text(label="Model prediction")
@@ -133,10 +93,11 @@ with gr.Blocks() as demo:
133
 
134
  ax.set_xlabel("Variables")
135
  ax.set_ylabel("Values")
136
- ax.set_title("Comparison of Reference and User Values")
137
  ax.set_xticks(indices + bar_width / 2)
138
  ax.set_xticklabels(categories)
139
 
 
140
  return res, fig
141
 
142
  btn.click(
@@ -144,18 +105,5 @@ with gr.Blocks() as demo:
144
  inputs=[age_input, bmi_input, hba1c_input, blood_glucose_input],
145
  outputs=[output, plot],
146
  )
147
- # demo = gr.Interface(
148
- # fn=diabetes,
149
- # title="Diabetes Prediction",
150
- # description="Fill these values with yours",
151
- # allow_flagging="never",
152
- # inputs=[
153
- # gr.Number(label="age"),
154
- # gr.Slider(10, 100, label="bmi", info="Body Mass Index"),
155
- # gr.Slider(3.5, 9, label="hba1c_level", info="Glycated Haemoglobin"),
156
- # gr.Slider(80, 300, label="blood_glucose_level", info="Blood Glucose Level"),
157
- # ],
158
- # outputs=gr.Number(label="diabetes"),
159
- # )
160
 
161
  demo.launch()
 
27
  )
28
  diabetes_df = pd.DataFrame(diabetes_fg.read())
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  with gr.Blocks() as demo:
31
  with gr.Row():
32
  gr.HTML(value="<h1 style='text-align: center;'>Diabetes prediction</h1>")
 
40
  blood_glucose_input = gr.Slider(
41
  80, 300, label="blood_glucose_level", info="Blood Glucose Level"
42
  )
43
+ gr.Radio(
44
+ ["yes", "no"],
45
+ label="if you already know that you have diabetes, select yes, else select no",
46
+ )
47
+ gr.Checkbox(
48
+ info="I consent that my personal data can be used to retrain the model"
49
+ )
50
  btn = gr.Button("Submit")
51
  with gr.Column():
52
  output = gr.Text(label="Model prediction")
 
93
 
94
  ax.set_xlabel("Variables")
95
  ax.set_ylabel("Values")
96
+ ax.set_title("Comparison with Mean values for your age")
97
  ax.set_xticks(indices + bar_width / 2)
98
  ax.set_xticklabels(categories)
99
 
100
+ ## save user's data in hopsworks
101
  return res, fig
102
 
103
  btn.click(
 
105
  inputs=[age_input, bmi_input, hba1c_input, blood_glucose_input],
106
  outputs=[output, plot],
107
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  demo.launch()