File size: 1,292 Bytes
d8bfe4a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
# 设置字体为 Times New Roman(需确保系统已安装)
plt.rcParams['font.family'] = 'Times New Roman'
# 原始数据
datas = [
[2.674, 0.814, 0.579, 5.69, 2.51],
[2.543, 0.823, 0.584, 5.31, 2.56],
[2.411, 0.837, 0.591, 4.87, 2.59],
[2.174, 0.866, 0.595, 4.21, 2.66],
[2.276, 0.861, 0.594, 4.47, 2.62],
[2.310, 0.855, 0.593, 4.68, 2.59],
]
metrics = ["CER", "Emo2V.", "S-SIM", "DNSV", "AutoPCP"]
x_labels = [0, 100, 200, 500, 1000, 2000]
# 转为 DataFrame
df = pd.DataFrame(datas, columns=metrics)
df['Step'] = x_labels
# 归一化指标
scaler = MinMaxScaler()
df_scaled = df.copy()
df_scaled[metrics] = scaler.fit_transform(df[metrics])
# 绘图(提高分辨率 dpi=300)
plt.figure(figsize=(8, 4), dpi=300)
for metric in metrics:
plt.plot(df_scaled["Step"], df_scaled[metric], label=metric, linewidth=2)
# plt.xlabel("Training Data Size (H)", fontsize=14)
# plt.ylabel("Normalized Score", fontsize=14)
plt.xticks(x_labels, fontsize=16)
plt.yticks(fontsize=16)
plt.legend(fontsize=16)
plt.grid(True)
plt.tight_layout()
# 保存图像(可选)
plt.savefig("examples/celsds/infer/evaluate/normalized_metric_trends.png", dpi=300)
plt.show()
|