Spaces:
Runtime error
Runtime error
add prediction result with users data
Browse files
app.py
CHANGED
|
@@ -86,9 +86,9 @@ with gr.Blocks() as demo:
|
|
| 86 |
)
|
| 87 |
res = model.predict(df)
|
| 88 |
if res == [0]:
|
| 89 |
-
|
| 90 |
elif res == [1]:
|
| 91 |
-
|
| 92 |
mean_for_age = diabetes_df[
|
| 93 |
(diabetes_df["diabetes"] == 0) & (diabetes_df["age"] == age_input)
|
| 94 |
].mean()
|
|
@@ -190,16 +190,23 @@ with gr.Blocks() as demo:
|
|
| 190 |
if consent_input == "accept":
|
| 191 |
print("user consented to save their data, now trying to save to hopsworks")
|
| 192 |
user_data_fg = fs.get_or_create_feature_group(
|
| 193 |
-
name="
|
| 194 |
version=1,
|
| 195 |
-
primary_key=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
description="Submitted user data",
|
| 197 |
)
|
| 198 |
user_data_df = df.copy()
|
| 199 |
user_data_df["diabetes"] = existent_info_input
|
|
|
|
| 200 |
user_data_fg.insert(user_data_df)
|
| 201 |
print("inserted new user data to hopsworks", user_data_df)
|
| 202 |
-
return
|
| 203 |
|
| 204 |
btn.click(
|
| 205 |
submit_inputs,
|
|
|
|
| 86 |
)
|
| 87 |
res = model.predict(df)
|
| 88 |
if res == [0]:
|
| 89 |
+
res_str = "the model prediction is: You don't have diabetes"
|
| 90 |
elif res == [1]:
|
| 91 |
+
res_str = "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()
|
|
|
|
| 190 |
if consent_input == "accept":
|
| 191 |
print("user consented to save their data, now trying to save to hopsworks")
|
| 192 |
user_data_fg = fs.get_or_create_feature_group(
|
| 193 |
+
name="diabetes_user_data",
|
| 194 |
version=1,
|
| 195 |
+
primary_key=[
|
| 196 |
+
"age",
|
| 197 |
+
"bmi",
|
| 198 |
+
"hba1c_level",
|
| 199 |
+
"blood_glucose_level",
|
| 200 |
+
"diabetes",
|
| 201 |
+
],
|
| 202 |
description="Submitted user data",
|
| 203 |
)
|
| 204 |
user_data_df = df.copy()
|
| 205 |
user_data_df["diabetes"] = existent_info_input
|
| 206 |
+
user_data_df["model_prediction"] = res[0]
|
| 207 |
user_data_fg.insert(user_data_df)
|
| 208 |
print("inserted new user data to hopsworks", user_data_df)
|
| 209 |
+
return res_str, fig, fig2, fig3, fig4, fig5
|
| 210 |
|
| 211 |
btn.click(
|
| 212 |
submit_inputs,
|