Update my_pages/ica.py
Browse files- my_pages/ica.py +12 -19
my_pages/ica.py
CHANGED
|
@@ -78,9 +78,9 @@ def render():
|
|
| 78 |
fig, ax = plt.subplots()
|
| 79 |
ax.plot(*np.append(vertices, [vertices[0]], axis=0).T)
|
| 80 |
# ax.scatter(vertices[:,0], vertices[:,1], c=["blue", "green", "red"], s=100)
|
| 81 |
-
ax.text(*vertices[0], "Intentional", ha="center", va="bottom")
|
| 82 |
-
ax.text(*vertices[1], "Conventional", ha="right", va="top")
|
| 83 |
-
ax.text(*vertices[2], "Arbitrary", ha="left", va="top")
|
| 84 |
ax.scatter(point[0], point[1], c="white", s=10000)
|
| 85 |
ax.scatter(point[0], point[1], c="orange", s=10000, zorder=5, alpha=0.3)
|
| 86 |
ax.set_aspect("equal")
|
|
@@ -92,33 +92,26 @@ def render():
|
|
| 92 |
# --- Dummy points scattered inside triangle ---
|
| 93 |
# (x, y, text)
|
| 94 |
locations = [
|
| 95 |
-
(0.
|
| 96 |
-
(0.7, 0.25, "Example B"),
|
| 97 |
-
(0.5, 0.6, "Example C"),
|
| 98 |
-
(0.2, 0.4, "Example D"),
|
| 99 |
-
(0.8, 0.5, "Example E"),
|
| 100 |
]
|
| 101 |
|
| 102 |
torch_radius = 0.177 # how far the "torch" illuminates
|
| 103 |
|
| 104 |
# Illuminate nearby points
|
| 105 |
-
for (x, y, label) in locations:
|
| 106 |
dist = np.linalg.norm([x - point[0], y - point[1]])
|
| 107 |
if dist <= torch_radius:
|
| 108 |
ax.scatter(x, y, c="red", s=50, zorder=6)
|
| 109 |
-
ax.text(x, y + 0.03, label, ha=
|
|
|
|
|
|
|
| 110 |
|
| 111 |
st.pyplot(fig)
|
| 112 |
|
| 113 |
-
# Display interpretation
|
| 114 |
-
closest = max(w.items(), key=lambda x: x[1])[0]
|
| 115 |
-
if closest == "Arbitrary":
|
| 116 |
-
st.info("Example: Random seeds — a truly arbitrary decision.")
|
| 117 |
-
elif closest == "Intentional":
|
| 118 |
-
st.info("Example: Ethical constraints — a fully intentional choice.")
|
| 119 |
-
elif closest == "Conventional":
|
| 120 |
-
st.info("Example: Industry standard preprocessing — a conventional decision.")
|
| 121 |
-
|
| 122 |
st.markdown("---")
|
| 123 |
col1, col2, col3, col4 = st.columns([2, 1, 1, 1])
|
| 124 |
with col3:
|
|
|
|
| 78 |
fig, ax = plt.subplots()
|
| 79 |
ax.plot(*np.append(vertices, [vertices[0]], axis=0).T)
|
| 80 |
# ax.scatter(vertices[:,0], vertices[:,1], c=["blue", "green", "red"], s=100)
|
| 81 |
+
ax.text(*vertices[0], "Intentional", ha="center", va="bottom", color="green")
|
| 82 |
+
ax.text(*vertices[1], "Conventional", ha="right", va="top", color="green")
|
| 83 |
+
ax.text(*vertices[2], "Arbitrary", ha="left", va="top", color="green")
|
| 84 |
ax.scatter(point[0], point[1], c="white", s=10000)
|
| 85 |
ax.scatter(point[0], point[1], c="orange", s=10000, zorder=5, alpha=0.3)
|
| 86 |
ax.set_aspect("equal")
|
|
|
|
| 92 |
# --- Dummy points scattered inside triangle ---
|
| 93 |
# (x, y, text)
|
| 94 |
locations = [
|
| 95 |
+
(0.9, 0.1, r"$\mathbf{Random\ Seeds}$\nHighly arbitrary, low conventional, low intentional: random", "left", "bottom"),
|
| 96 |
+
(0.7, 0.25, "Example B", "left", "bottom"),
|
| 97 |
+
(0.5, 0.6, "Example C", "left", "bottom"),
|
| 98 |
+
(0.2, 0.4, "Example D", "left", "bottom"),
|
| 99 |
+
(0.8, 0.5, "Example E", "left", "bottom"),
|
| 100 |
]
|
| 101 |
|
| 102 |
torch_radius = 0.177 # how far the "torch" illuminates
|
| 103 |
|
| 104 |
# Illuminate nearby points
|
| 105 |
+
for (x, y, label, ha, va) in locations:
|
| 106 |
dist = np.linalg.norm([x - point[0], y - point[1]])
|
| 107 |
if dist <= torch_radius:
|
| 108 |
ax.scatter(x, y, c="red", s=50, zorder=6)
|
| 109 |
+
ax.text(x, y + 0.03, label, ha=ha, va=va, color="red", zorder=6)
|
| 110 |
+
else:
|
| 111 |
+
ax.scatter(x, y, c="red", s=50, zorder=6, alpha=0.3)
|
| 112 |
|
| 113 |
st.pyplot(fig)
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
st.markdown("---")
|
| 116 |
col1, col2, col3, col4 = st.columns([2, 1, 1, 1])
|
| 117 |
with col3:
|