Jay1121 commited on
Commit
fbc3bcb
ยท
verified ยท
1 Parent(s): ea89954

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -28
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, yaxis_title="SNR",
2131
- height=ROW2_GRAPH_H if 'ROW2_GRAPH_H' in globals() else 320,
2132
- paper_bgcolor="#fff", plot_bgcolor="#fff",
2133
- margin=dict(l=10, r=10, t=56, b=52), # โ† ์ƒ๋‹จ/ํ•˜๋‹จ ์—ฌ์œ  ํฌ๊ฒŒ
2134
  showlegend=False,
2135
- uirevision="keep",
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
- xref="x domain", yref="paper", x=1, y=-0.10,
2158
- text="Lift vs Galaxy", showarrow=False,
2159
- xanchor="right", yanchor="top", font=dict(size=12)
 
 
 
 
 
 
2160
  )
 
 
2161
 
2162
- # shape ์ž”์žฌ ์ •๋ฆฌ(์žˆ์œผ๋ฉด)
2163
- try:
2164
- fig = _scrub_layout_shapes(fig)
2165
- except Exception:
2166
- pass
 
 
 
 
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