Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2028,6 +2028,7 @@ def bubble_figure(
|
|
| 2028 |
return _empty_fig("No Bubble key")
|
| 2029 |
|
| 2030 |
need_cols = [key, lift_col, snr_col, "pref_sample_size"]
|
|
|
|
| 2031 |
if "segment" in s.columns and "segment" not in need_cols:
|
| 2032 |
need_cols.append("segment")
|
| 2033 |
|
|
@@ -2035,7 +2036,7 @@ def bubble_figure(
|
|
| 2035 |
if use.empty:
|
| 2036 |
return _empty_fig("No Bubble values")
|
| 2037 |
|
| 2038 |
-
# ---- ์ง๊ณ ----
|
| 2039 |
if "segment" in use.columns:
|
| 2040 |
grp = (use.groupby(key, as_index=False)
|
| 2041 |
.agg(x=(lift_col, "mean"),
|
|
@@ -2047,6 +2048,7 @@ def bubble_figure(
|
|
| 2047 |
.agg(x=(lift_col, "mean"),
|
| 2048 |
y=(snr_col, "mean"),
|
| 2049 |
n=("pref_sample_size", "sum")))
|
|
|
|
| 2050 |
grp["seg"] = np.nan
|
| 2051 |
|
| 2052 |
# ---- ์์ ----
|
|
@@ -2093,18 +2095,20 @@ def bubble_figure(
|
|
| 2093 |
x0, x1 = x_min - x_pad, x_max + x_pad
|
| 2094 |
y0, y1 = y_min - y_pad, y_max + y_pad
|
| 2095 |
|
| 2096 |
-
winner_fill = hex_to_rgba("#FDE68A", 0.16)
|
| 2097 |
-
loser_fill = hex_to_rgba("#9CA3AF", 0.14)
|
| 2098 |
|
| 2099 |
fig = go.Figure()
|
| 2100 |
|
| 2101 |
-
# ์์ ์์ญ
|
| 2102 |
add_vrect_safe(fig, x0, x_thr, y0=y_thr, y1=y1, fillcolor=loser_fill, layer="below")
|
| 2103 |
add_vrect_safe(fig, x_thr, x1, y0=y_thr, y1=y1, fillcolor=winner_fill, layer="below")
|
|
|
|
|
|
|
| 2104 |
add_vline_safe(fig, x_thr, line_dash="dot", line_color="#888", opacity=0.6)
|
| 2105 |
add_hline_safe(fig, y_thr, line_dash="dot", line_color="#888", opacity=0.6)
|
| 2106 |
|
| 2107 |
-
# ๋ฒ๋ธ
|
| 2108 |
fig.add_trace(go.Scatter(
|
| 2109 |
x=grp["x"], y=grp["y"],
|
| 2110 |
mode="markers+text",
|
|
@@ -2124,24 +2128,18 @@ def bubble_figure(
|
|
| 2124 |
name="๋ชจ๋ธ/์ธ๊ทธ"
|
| 2125 |
))
|
| 2126 |
|
| 2127 |
-
# ๋ ์ด์์
|
| 2128 |
fig.update_layout(
|
| 2129 |
title="Lift vs SNR (๋ฒ๋ธ=ํ๋ณธ์)",
|
| 2130 |
-
xaxis_title=None,
|
| 2131 |
-
|
| 2132 |
-
|
| 2133 |
-
margin=dict(l=10, r=10, t=56, b=52), # โ ์๋จ/ํ๋จ ์ฌ์ ํฌ๊ฒ
|
| 2134 |
showlegend=False,
|
| 2135 |
-
|
| 2136 |
-
|
| 2137 |
-
fig.update_xaxes(
|
| 2138 |
-
showgrid=True, gridcolor="#e5e7eb", gridwidth=0.8, zeroline=False,
|
| 2139 |
-
title_standoff=18, automargin=True
|
| 2140 |
-
)
|
| 2141 |
-
fig.update_yaxes(
|
| 2142 |
-
showgrid=True, gridcolor="#e5e7eb", gridwidth=0.8, zeroline=False,
|
| 2143 |
-
title_standoff=8, automargin=True
|
| 2144 |
)
|
|
|
|
|
|
|
| 2145 |
|
| 2146 |
# ๊ฐ์ฃผ
|
| 2147 |
foot_y = -0.20
|
|
@@ -2153,17 +2151,29 @@ def bubble_figure(
|
|
| 2153 |
text="<b>โ </b>", showarrow=False, font=dict(size=11, color="#9CA3AF"))
|
| 2154 |
fig.add_annotation(xref="paper", yref="paper", x=0.355, y=foot_y,
|
| 2155 |
text="ํจ์ ์์ญ (Liftโ, SNRโ)", showarrow=False, font=dict(size=10, color="#555"), xanchor="left")
|
| 2156 |
-
fig.add_annotation(
|
| 2157 |
-
|
| 2158 |
-
|
| 2159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2160 |
)
|
|
|
|
|
|
|
| 2161 |
|
| 2162 |
-
#
|
| 2163 |
-
|
| 2164 |
-
|
| 2165 |
-
|
| 2166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2167 |
|
| 2168 |
return fig
|
| 2169 |
|
|
|
|
| 2028 |
return _empty_fig("No Bubble key")
|
| 2029 |
|
| 2030 |
need_cols = [key, lift_col, snr_col, "pref_sample_size"]
|
| 2031 |
+
# ์์ผ๋ฉด segment๋ฅผ ์ถ๊ฐ(์์์ฉ)
|
| 2032 |
if "segment" in s.columns and "segment" not in need_cols:
|
| 2033 |
need_cols.append("segment")
|
| 2034 |
|
|
|
|
| 2036 |
if use.empty:
|
| 2037 |
return _empty_fig("No Bubble values")
|
| 2038 |
|
| 2039 |
+
# ---- ์ง๊ณ (segment ์ ๋ฌด์ ๋ฐ๋ผ ๋ถ๊ธฐ) ----
|
| 2040 |
if "segment" in use.columns:
|
| 2041 |
grp = (use.groupby(key, as_index=False)
|
| 2042 |
.agg(x=(lift_col, "mean"),
|
|
|
|
| 2048 |
.agg(x=(lift_col, "mean"),
|
| 2049 |
y=(snr_col, "mean"),
|
| 2050 |
n=("pref_sample_size", "sum")))
|
| 2051 |
+
# ์์ ํจ์๊ฐ ์ฐธ์กฐํ๋ seg ์ปฌ๋ผ ๋ณด๊ฐ(์์ผ๋ฉด NaN)
|
| 2052 |
grp["seg"] = np.nan
|
| 2053 |
|
| 2054 |
# ---- ์์ ----
|
|
|
|
| 2095 |
x0, x1 = x_min - x_pad, x_max + x_pad
|
| 2096 |
y0, y1 = y_min - y_pad, y_max + y_pad
|
| 2097 |
|
| 2098 |
+
winner_fill = hex_to_rgba("#FDE68A", 0.16) # ์น์(์ฐ๋
ธ๋)
|
| 2099 |
+
loser_fill = hex_to_rgba("#9CA3AF", 0.14) # ํจ์(์ฐํ์)
|
| 2100 |
|
| 2101 |
fig = go.Figure()
|
| 2102 |
|
| 2103 |
+
# ์์ ์์ญ(์์ ์ฌ๊ฐํ ํฌํผ ์ฌ์ฉ)
|
| 2104 |
add_vrect_safe(fig, x0, x_thr, y0=y_thr, y1=y1, fillcolor=loser_fill, layer="below")
|
| 2105 |
add_vrect_safe(fig, x_thr, x1, y0=y_thr, y1=y1, fillcolor=winner_fill, layer="below")
|
| 2106 |
+
|
| 2107 |
+
# ๊ฒฝ๊ณ์ (์์ ๋ฒ์ )
|
| 2108 |
add_vline_safe(fig, x_thr, line_dash="dot", line_color="#888", opacity=0.6)
|
| 2109 |
add_hline_safe(fig, y_thr, line_dash="dot", line_color="#888", opacity=0.6)
|
| 2110 |
|
| 2111 |
+
# ---- ๋ฒ๋ธ (โ
_trace โ add_trace) ----
|
| 2112 |
fig.add_trace(go.Scatter(
|
| 2113 |
x=grp["x"], y=grp["y"],
|
| 2114 |
mode="markers+text",
|
|
|
|
| 2128 |
name="๋ชจ๋ธ/์ธ๊ทธ"
|
| 2129 |
))
|
| 2130 |
|
| 2131 |
+
# ๋ ์ด์์
|
| 2132 |
fig.update_layout(
|
| 2133 |
title="Lift vs SNR (๋ฒ๋ธ=ํ๋ณธ์)",
|
| 2134 |
+
xaxis_title=None,
|
| 2135 |
+
yaxis_title="SNR",
|
| 2136 |
+
height=320,
|
|
|
|
| 2137 |
showlegend=False,
|
| 2138 |
+
paper_bgcolor="#fff", plot_bgcolor="#fff",
|
| 2139 |
+
margin=dict(l=10, r=10, t=26, b=48)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2140 |
)
|
| 2141 |
+
fig.update_xaxes(title_standoff=18, automargin=True)
|
| 2142 |
+
fig.update_yaxes(title_standoff=8, automargin=True)
|
| 2143 |
|
| 2144 |
# ๊ฐ์ฃผ
|
| 2145 |
foot_y = -0.20
|
|
|
|
| 2151 |
text="<b>โ </b>", showarrow=False, font=dict(size=11, color="#9CA3AF"))
|
| 2152 |
fig.add_annotation(xref="paper", yref="paper", x=0.355, y=foot_y,
|
| 2153 |
text="ํจ์ ์์ญ (Liftโ, SNRโ)", showarrow=False, font=dict(size=10, color="#555"), xanchor="left")
|
| 2154 |
+
fig.add_annotation(xref="paper", yref="paper", x=0.67, y=foot_y,
|
| 2155 |
+
text="โ ์ ํฌ๊ธฐ = ํ๋ณธ์(โ์ค์ผ์ผ)", showarrow=False, font=dict(size=10, color="#666"), xanchor="left")
|
| 2156 |
+
|
| 2157 |
+
# ๊ณตํต ์คํ์ผ ํ ์ฌ๊ณ ์
|
| 2158 |
+
fig = apply_dense_grid(fig)
|
| 2159 |
+
fig.update_layout(
|
| 2160 |
+
height=ROW2_GRAPH_H,
|
| 2161 |
+
margin=dict(l=10, r=10, t=44, b=48),
|
| 2162 |
+
showlegend=False,
|
| 2163 |
+
xaxis_title=None
|
| 2164 |
)
|
| 2165 |
+
fig.update_xaxes(title_standoff=18, automargin=True)
|
| 2166 |
+
fig.update_yaxes(title_standoff=8, automargin=True)
|
| 2167 |
|
| 2168 |
+
# x์ถ ์ ๋ชฉ์ annotation์ผ๋ก
|
| 2169 |
+
fig.add_annotation(
|
| 2170 |
+
text="Lift vs Galaxy",
|
| 2171 |
+
xref="x domain", yref="paper",
|
| 2172 |
+
x=1, y=-0.10,
|
| 2173 |
+
xanchor="right", yanchor="top",
|
| 2174 |
+
showarrow=False,
|
| 2175 |
+
font=dict(size=12)
|
| 2176 |
+
)
|
| 2177 |
|
| 2178 |
return fig
|
| 2179 |
|