(results, file_name="rho_vs_acc.png", dir_path=str)
| 277 | |
| 278 | |
| 279 | def plot_sr(results, file_name="rho_vs_acc.png", dir_path=str): |
| 280 | # 输出目录 |
| 281 | # dir_path = r"E:\weichy\ODECode\src\output\Plot\ode" |
| 282 | os.makedirs(dir_path, exist_ok=True) |
| 283 | |
| 284 | # 将 results 解包为三个列表 |
| 285 | spectral_radii, train_accs, test_accs = zip(*results) |
| 286 | |
| 287 | # 绘图 |
| 288 | plt.figure() |
| 289 | plt.plot(spectral_radii, train_accs, marker='o', label='Train Accuracy') |
| 290 | plt.plot(spectral_radii, test_accs, marker='s', label='Test Accuracy') |
| 291 | plt.xlabel("spectral_radius") |
| 292 | plt.ylabel("accuracy") |
| 293 | plt.title("Spectral Radius vs Accuracy") |
| 294 | plt.legend() # 添加图例 |
| 295 | plt.tight_layout() |
| 296 | |
| 297 | # 保存并关闭 |
| 298 | file_path = os.path.join(dir_path, file_name) |
| 299 | plt.savefig(file_path, dpi=300) |
| 300 | plt.close() |
| 301 | |
| 302 | |
| 303 | def evaluate_classifiers_and_tsne_from_npz(npz_path, save_dir, spectral_radius, fit_total_time, seed=42, logger=None): |
nothing calls this directly
no outgoing calls
no test coverage detected