Jellyfish042 commited on
Commit
bfa965f
·
1 Parent(s): dc5333c
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -78,6 +78,16 @@ def build_fit_line_hovertemplate(label, a, b, c, raw_rmse, log_rmse):
78
  )
79
 
80
 
 
 
 
 
 
 
 
 
 
 
81
  def read_about_md():
82
  with open("about.md", "r", encoding="utf-8") as f:
83
  return f.read()
@@ -950,14 +960,14 @@ def create_scaling_plot(data_manager: DataManager, period: str, use_pareto: bool
950
  x=fit_x.tolist(),
951
  y=fit_y.tolist(),
952
  mode="lines",
953
- name=fit_type,
954
  line=dict(color=FIT_LINE_COLOR, width=2, dash="dash"),
955
  hovertemplate=build_fit_line_hovertemplate(fit_type, a, b, c, raw_rmse, log_rmse),
956
  )
957
  )
958
-
959
- title_suffix = " (Pareto Frontier)" if use_pareto else ""
960
- fig.update_layout(
961
  title={"text": f"Compression Ratio Scaling Law{title_suffix}", "x": 0.5, "xanchor": "center", "yanchor": "top"},
962
  width=SCALING_PLOT_WIDTH,
963
  height=SCALING_PLOT_HEIGHT,
@@ -1040,8 +1050,7 @@ def create_category_scaling_plot(
1040
  all_x_values = []
1041
  all_y_values = []
1042
  all_delta_values = []
1043
-
1044
- if display_mode == "average":
1045
  # 平均模式:计算选中数据集的平均值
1046
  x_values = new_df["Params (B)"].astype(float).tolist()
1047
  names = new_df["Name"].tolist()
@@ -1155,12 +1164,15 @@ def create_category_scaling_plot(
1155
  # 添加拟合曲线
1156
  fit_type = "Pareto Fit" if use_pareto else "Fit"
1157
  fit_label = f"{datasets_label} ({fit_type})"
 
 
 
1158
  fig.add_trace(
1159
  go.Scatter(
1160
  x=fit_x.tolist(),
1161
  y=fit_y.tolist(),
1162
  mode="lines",
1163
- name=fit_label,
1164
  line=dict(color=FIT_LINE_COLOR, width=2, dash="dash"),
1165
  hovertemplate=build_fit_line_hovertemplate(fit_label, a, b, c, raw_rmse, log_rmse),
1166
  )
@@ -1301,12 +1313,15 @@ def create_category_scaling_plot(
1301
  # 添加拟合曲线
1302
  fit_type = "Pareto Fit" if use_pareto else "Fit"
1303
  fit_label = f"{dataset} ({fit_type})"
 
 
 
1304
  fig.add_trace(
1305
  go.Scatter(
1306
  x=fit_x.tolist(),
1307
  y=fit_y.tolist(),
1308
  mode="lines",
1309
- name=dataset,
1310
  line=dict(color=color, width=2, dash="dash"),
1311
  hovertemplate=build_fit_line_hovertemplate(fit_label, a, b, c, raw_rmse, log_rmse),
1312
  legendgroup=dataset,
 
78
  )
79
 
80
 
81
+ def build_fit_summary_legend_text(label, a, b, c, raw_rmse, log_rmse, include_label=True):
82
+ parts = []
83
+ if include_label and label:
84
+ parts.append(label)
85
+ parts.append(format_fit_equation(a, b, c))
86
+ parts.append(f"Raw RMSE: {raw_rmse:.2f}")
87
+ parts.append(f"Log-RMSE: {log_rmse:.3f}")
88
+ return "<br>".join(parts)
89
+
90
+
91
  def read_about_md():
92
  with open("about.md", "r", encoding="utf-8") as f:
93
  return f.read()
 
960
  x=fit_x.tolist(),
961
  y=fit_y.tolist(),
962
  mode="lines",
963
+ name=build_fit_summary_legend_text(fit_type, a, b, c, raw_rmse, log_rmse),
964
  line=dict(color=FIT_LINE_COLOR, width=2, dash="dash"),
965
  hovertemplate=build_fit_line_hovertemplate(fit_type, a, b, c, raw_rmse, log_rmse),
966
  )
967
  )
968
+
969
+ title_suffix = " (Pareto Frontier)" if use_pareto else ""
970
+ fig.update_layout(
971
  title={"text": f"Compression Ratio Scaling Law{title_suffix}", "x": 0.5, "xanchor": "center", "yanchor": "top"},
972
  width=SCALING_PLOT_WIDTH,
973
  height=SCALING_PLOT_HEIGHT,
 
1050
  all_x_values = []
1051
  all_y_values = []
1052
  all_delta_values = []
1053
+ if display_mode == "average":
 
1054
  # 平均模式:计算选中数据集的平均值
1055
  x_values = new_df["Params (B)"].astype(float).tolist()
1056
  names = new_df["Name"].tolist()
 
1164
  # 添加拟合曲线
1165
  fit_type = "Pareto Fit" if use_pareto else "Fit"
1166
  fit_label = f"{datasets_label} ({fit_type})"
1167
+ fit_legend_name = fit_label
1168
+ if len(selected_datasets) == 1:
1169
+ fit_legend_name = build_fit_summary_legend_text(fit_label, a, b, c, raw_rmse, log_rmse)
1170
  fig.add_trace(
1171
  go.Scatter(
1172
  x=fit_x.tolist(),
1173
  y=fit_y.tolist(),
1174
  mode="lines",
1175
+ name=fit_legend_name,
1176
  line=dict(color=FIT_LINE_COLOR, width=2, dash="dash"),
1177
  hovertemplate=build_fit_line_hovertemplate(fit_label, a, b, c, raw_rmse, log_rmse),
1178
  )
 
1313
  # 添加拟合曲线
1314
  fit_type = "Pareto Fit" if use_pareto else "Fit"
1315
  fit_label = f"{dataset} ({fit_type})"
1316
+ fit_legend_name = dataset
1317
+ if len(selected_datasets) == 1:
1318
+ fit_legend_name = build_fit_summary_legend_text(dataset, a, b, c, raw_rmse, log_rmse)
1319
  fig.add_trace(
1320
  go.Scatter(
1321
  x=fit_x.tolist(),
1322
  y=fit_y.tolist(),
1323
  mode="lines",
1324
+ name=fit_legend_name,
1325
  line=dict(color=color, width=2, dash="dash"),
1326
  hovertemplate=build_fit_line_hovertemplate(fit_label, a, b, c, raw_rmse, log_rmse),
1327
  legendgroup=dataset,