pantdipendra
commited on
v7 plot
Browse files
app.py
CHANGED
@@ -385,17 +385,17 @@ def predict(
|
|
385 |
)
|
386 |
fig_in.update_layout(width=1200, height=400)
|
387 |
|
388 |
-
# 8) Bar chart for predicted labels
|
389 |
label_df_list = []
|
390 |
for lbl_col, (pred_val, _) in label_prediction_info.items():
|
391 |
if lbl_col in df.columns:
|
392 |
# Count how many patients in df have the predicted value
|
393 |
predicted_count = len(df[df[lbl_col] == pred_val])
|
394 |
-
|
395 |
# Determine the "other" class (0 ↔ 1)
|
396 |
other_val = 1 - pred_val
|
397 |
other_count = len(df[df[lbl_col] == other_val])
|
398 |
-
|
399 |
label_df_list.append({
|
400 |
"Label": lbl_col,
|
401 |
"Class": f"Predicted_{pred_val}",
|
@@ -406,7 +406,7 @@ def predict(
|
|
406 |
"Class": f"Opposite_{other_val}",
|
407 |
"Count": other_count
|
408 |
})
|
409 |
-
|
410 |
if label_df_list:
|
411 |
bar_lbl_df = pd.DataFrame(label_df_list)
|
412 |
fig_lbl = px.bar(
|
@@ -422,6 +422,14 @@ def predict(
|
|
422 |
fig_lbl = px.bar(title="No valid predicted labels to display.")
|
423 |
fig_lbl.update_layout(width=1200, height=400)
|
424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
|
426 |
######################################
|
427 |
# 6) UNIFIED DISTRIBUTION/CO-OCCURRENCE
|
|
|
385 |
)
|
386 |
fig_in.update_layout(width=1200, height=400)
|
387 |
|
388 |
+
# 8) Bar chart for predicted labels (UPDATED)
|
389 |
label_df_list = []
|
390 |
for lbl_col, (pred_val, _) in label_prediction_info.items():
|
391 |
if lbl_col in df.columns:
|
392 |
# Count how many patients in df have the predicted value
|
393 |
predicted_count = len(df[df[lbl_col] == pred_val])
|
394 |
+
|
395 |
# Determine the "other" class (0 ↔ 1)
|
396 |
other_val = 1 - pred_val
|
397 |
other_count = len(df[df[lbl_col] == other_val])
|
398 |
+
|
399 |
label_df_list.append({
|
400 |
"Label": lbl_col,
|
401 |
"Class": f"Predicted_{pred_val}",
|
|
|
406 |
"Class": f"Opposite_{other_val}",
|
407 |
"Count": other_count
|
408 |
})
|
409 |
+
|
410 |
if label_df_list:
|
411 |
bar_lbl_df = pd.DataFrame(label_df_list)
|
412 |
fig_lbl = px.bar(
|
|
|
422 |
fig_lbl = px.bar(title="No valid predicted labels to display.")
|
423 |
fig_lbl.update_layout(width=1200, height=400)
|
424 |
|
425 |
+
return (
|
426 |
+
final_str, # 1) Prediction Results
|
427 |
+
severity_msg, # 2) Mental Health Severity
|
428 |
+
total_count_md, # 3) Total Patient Count
|
429 |
+
nn_md, # 4) Nearest Neighbors Summary
|
430 |
+
fig_in, # 5) Bar Chart (input features)
|
431 |
+
fig_lbl # 6) Bar Chart (labels)
|
432 |
+
)
|
433 |
|
434 |
######################################
|
435 |
# 6) UNIFIED DISTRIBUTION/CO-OCCURRENCE
|