MCPcopy Create free account
hub / github.com/LeMo-CtRes/CtRes / plot_sr

Function plot_sr

utils/utils_ode.py:442–463  ·  view source on GitHub ↗
(results, file_name="rho_vs_acc.png", dir_path=str)

Source from the content-addressed store, hash-verified

440 print(f"Legend saved to: {legend_path}")
441
442def plot_sr(results, file_name="rho_vs_acc.png", dir_path=str):
443 # 输出目录
444 # dir_path = r"E:\weichy\ODECode\src\output\Plot\ode"
445 os.makedirs(dir_path, exist_ok=True)
446
447 # 将 results 解包为三个列表
448 spectral_radii, train_accs, test_accs = zip(*results)
449
450 # 绘图
451 plt.figure()
452 plt.plot(spectral_radii, train_accs, marker='o', label='Train Accuracy')
453 plt.plot(spectral_radii, test_accs, marker='s', label='Test Accuracy')
454 plt.xlabel("spectral_radius")
455 plt.ylabel("accuracy")
456 plt.title("Spectral Radius vs Accuracy")
457 plt.legend() # 添加图例
458 plt.tight_layout()
459
460 # 保存并关闭
461 file_path = os.path.join(dir_path, file_name)
462 plt.savefig(file_path, dpi=300)
463 plt.close()
464
465
466

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected