|
|
|
|
@ -14,6 +14,10 @@ import matplotlib.pyplot as plt
|
|
|
|
|
# 控制是否打印的宏定义
|
|
|
|
|
PRINT_LOG = True
|
|
|
|
|
|
|
|
|
|
# 确保 matplotlib 支持中文
|
|
|
|
|
plt.rcParams['font.sans-serif'] = ['SimHei'] # 使用黑体
|
|
|
|
|
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像时负号 '-' 显示为方块的问题
|
|
|
|
|
|
|
|
|
|
def log_print(message):
|
|
|
|
|
logging.info(message)
|
|
|
|
|
if PRINT_LOG:
|
|
|
|
|
@ -181,11 +185,11 @@ class MLModel:
|
|
|
|
|
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 5))
|
|
|
|
|
ax1.plot(train_loss_history, label='Train Loss(训练损失)')
|
|
|
|
|
ax1.plot(val_loss_history, label='Validation Loss(验证损失)')
|
|
|
|
|
ax1.set_title('Loss')
|
|
|
|
|
ax1.set_title('Loss(损失)')
|
|
|
|
|
ax1.legend()
|
|
|
|
|
ax2.plot(train_acc_history, label='Train Accuracy(训练正确率)')
|
|
|
|
|
ax2.plot(val_acc_history, label='Validation Accuracy(验证正确率)')
|
|
|
|
|
ax2.set_title('Accuracy')
|
|
|
|
|
ax2.set_title('Accuracy(正确率)')
|
|
|
|
|
ax2.legend()
|
|
|
|
|
ax3.plot(val_f1_history, label='Validation F1(验证F1得分)')
|
|
|
|
|
ax3.plot(val_precision_history, label='Validation Precision(验证精确率)')
|
|
|
|
|
|