Update app.py
Browse files
app.py
CHANGED
|
@@ -424,30 +424,32 @@ if st.button("🚀 Run Topic Modeling Pipeline", type="primary", use_container_w
|
|
| 424 |
else:
|
| 425 |
ax4.text(0.5, 0.5, "Theme not found", ha='center', transform=ax4.transAxes)
|
| 426 |
|
| 427 |
-
|
| 428 |
-
# 5. KPI Dashboard
|
| 429 |
# --------------------------------------------------
|
| 430 |
ax5 = plt.subplot(3, 2, 5)
|
| 431 |
ax5.axis('off')
|
| 432 |
-
ax5.set_title("STEP 5: Post-Hoc Evaluation Formulas", fontsize=13, fontweight='bold', y=0.
|
| 433 |
|
| 434 |
-
# Get the actual distance metric used for the label
|
| 435 |
dist_used = ui_metric if algo_used == "UMAP" else "euclidean"
|
| 436 |
|
|
|
|
| 437 |
kpi_math = (
|
| 438 |
-
r"$\mathbf{
|
| 439 |
-
|
|
|
|
| 440 |
|
| 441 |
-
r"$\mathbf{
|
| 442 |
-
f"Live Calc: Score = {sil_status} (Using {dist_used} distance)\n\n"
|
| 443 |
|
| 444 |
-
r"$\mathbf{
|
| 445 |
-
f"Live Calc: Score = {npmi_status} across {len(all_words)} valid themes"
|
| 446 |
)
|
| 447 |
|
| 448 |
-
ax5.text(0.5, 0.
|
| 449 |
-
bbox=dict(boxstyle="square,pad=1.
|
| 450 |
-
|
|
|
|
|
|
|
|
|
|
| 451 |
# --------------------------------------------------
|
| 452 |
# 6. Summary Matrix Transformations
|
| 453 |
# --------------------------------------------------
|
|
|
|
| 424 |
else:
|
| 425 |
ax4.text(0.5, 0.5, "Theme not found", ha='center', transform=ax4.transAxes)
|
| 426 |
|
| 427 |
+
# --------------------------------------------------
|
| 428 |
+
# 5. KPI Dashboard (Updated with UMass)
|
| 429 |
# --------------------------------------------------
|
| 430 |
ax5 = plt.subplot(3, 2, 5)
|
| 431 |
ax5.axis('off')
|
| 432 |
+
ax5.set_title("STEP 5: Post-Hoc Evaluation Formulas", fontsize=13, fontweight='bold', y=0.95)
|
| 433 |
|
|
|
|
| 434 |
dist_used = ui_metric if algo_used == "UMAP" else "euclidean"
|
| 435 |
|
| 436 |
+
# Condensed to fit all 4 metrics beautifully!
|
| 437 |
kpi_math = (
|
| 438 |
+
r"$\mathbf{Diversity:} \quad D = \frac{| \text{Unique} |}{| \text{Total} |}$" + f" [Live: {div_status}]\n\n"
|
| 439 |
+
|
| 440 |
+
r"$\mathbf{Silhouette:} \quad S = \frac{b - a}{\max(a, b)}$" + f" [Live: {sil_status}]\n\n"
|
| 441 |
|
| 442 |
+
r"$\mathbf{NPMI:} \quad \frac{\log(P(x,y) / P(x)P(y))}{-\log P(x,y)}$" + f" [Live: {npmi_status}]\n\n"
|
|
|
|
| 443 |
|
| 444 |
+
r"$\mathbf{UMass:} \quad \log \frac{P(x,y) + \epsilon}{P(x)}$" + f" [Live: {umass_status}]"
|
|
|
|
| 445 |
)
|
| 446 |
|
| 447 |
+
ax5.text(0.5, 0.45, kpi_math, fontsize=12, va='center', ha='center',
|
| 448 |
+
bbox=dict(boxstyle="square,pad=1.2", facecolor='#e6f2ff', edgecolor='#377eb8', lw=2))
|
| 449 |
+
|
| 450 |
+
ax5.text(0.5, -0.15, "Math: UMass measures internal dataset logic. NPMI measures external logic.\nSilhouette measures geometric separation.",
|
| 451 |
+
fontsize=10, ha='center', va='top', transform=ax5.transAxes, bbox=box_style)
|
| 452 |
+
|
| 453 |
# --------------------------------------------------
|
| 454 |
# 6. Summary Matrix Transformations
|
| 455 |
# --------------------------------------------------
|