Spaces:
Runtime error
Runtime error
adjust graph, change ui model output
Browse files
app.py
CHANGED
@@ -49,9 +49,9 @@ with gr.Blocks() as demo:
|
|
49 |
["yes", "no", "Don't know"],
|
50 |
label="Do you already know if you have diabetes? (This will not be used for the prediction)",
|
51 |
)
|
52 |
-
consent_input = gr.
|
53 |
-
|
54 |
-
label="
|
55 |
)
|
56 |
btn = gr.Button("Submit")
|
57 |
with gr.Column():
|
@@ -85,7 +85,10 @@ with gr.Blocks() as demo:
|
|
85 |
columns=["age", "bmi", "hba1c_level", "blood_glucose_level"],
|
86 |
)
|
87 |
res = model.predict(df)
|
88 |
-
|
|
|
|
|
|
|
89 |
mean_for_age = diabetes_df[
|
90 |
(diabetes_df["diabetes"] == 0) & (diabetes_df["age"] == age_input)
|
91 |
].mean()
|
@@ -173,7 +176,10 @@ with gr.Blocks() as demo:
|
|
173 |
sns.barplot(x=feature_importances, y=["age", "bmi", "hba1c", "glucose"])
|
174 |
|
175 |
fig5 = plt.figure(figsize=(3, 3))
|
|
|
|
|
176 |
plt.title("SHAP Interaction Plot")
|
|
|
177 |
shap.decision_plot(
|
178 |
explainer.expected_value[predicted_class],
|
179 |
shap_values_for_predicted_class,
|
@@ -181,7 +187,7 @@ with gr.Blocks() as demo:
|
|
181 |
)
|
182 |
|
183 |
## save user's data in hopsworks
|
184 |
-
if consent_input ==
|
185 |
user_data_fg = fs.get_or_create_feature_group(
|
186 |
name="user_diabetes_data",
|
187 |
version=1,
|
|
|
49 |
["yes", "no", "Don't know"],
|
50 |
label="Do you already know if you have diabetes? (This will not be used for the prediction)",
|
51 |
)
|
52 |
+
consent_input = gr.Radio(
|
53 |
+
["accept", "decline"],
|
54 |
+
label="I consent that my personal data will be saved and potentially be used for the model training",
|
55 |
)
|
56 |
btn = gr.Button("Submit")
|
57 |
with gr.Column():
|
|
|
85 |
columns=["age", "bmi", "hba1c_level", "blood_glucose_level"],
|
86 |
)
|
87 |
res = model.predict(df)
|
88 |
+
if res == [0]:
|
89 |
+
res = "the model prediction is: You don't have diabetes"
|
90 |
+
elif res == [1]:
|
91 |
+
res = "the model prediction is: You have diabetes"
|
92 |
mean_for_age = diabetes_df[
|
93 |
(diabetes_df["diabetes"] == 0) & (diabetes_df["age"] == age_input)
|
94 |
].mean()
|
|
|
176 |
sns.barplot(x=feature_importances, y=["age", "bmi", "hba1c", "glucose"])
|
177 |
|
178 |
fig5 = plt.figure(figsize=(3, 3))
|
179 |
+
fig5.tight_layout()
|
180 |
+
plt.gca().set_position((0, 0, 1, 1))
|
181 |
plt.title("SHAP Interaction Plot")
|
182 |
+
plt.tight_layout()
|
183 |
shap.decision_plot(
|
184 |
explainer.expected_value[predicted_class],
|
185 |
shap_values_for_predicted_class,
|
|
|
187 |
)
|
188 |
|
189 |
## save user's data in hopsworks
|
190 |
+
if consent_input == "accept":
|
191 |
user_data_fg = fs.get_or_create_feature_group(
|
192 |
name="user_diabetes_data",
|
193 |
version=1,
|