|
|
|
@ -10,13 +10,18 @@ from sklearn.metrics import precision_score, recall_score, f1_score
|
|
|
|
from sklearn.utils.class_weight import compute_class_weight
|
|
|
|
from sklearn.utils.class_weight import compute_class_weight
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
from matplotlib.font_manager import FontProperties
|
|
|
|
|
|
|
|
|
|
|
|
# 控制是否打印的宏定义
|
|
|
|
# 控制是否打印的宏定义
|
|
|
|
PRINT_LOG = True
|
|
|
|
PRINT_LOG = True
|
|
|
|
|
|
|
|
|
|
|
|
# 确保 matplotlib 支持中文
|
|
|
|
# 指定字体路径
|
|
|
|
plt.rcParams['font.sans-serif'] = ['SimHei'] # 使用黑体
|
|
|
|
font_path = os.path.join(os.path.dirname(__file__), 'fonts', 'simhei.ttf')
|
|
|
|
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像时负号 '-' 显示为方块的问题
|
|
|
|
font_prop = FontProperties(fname=font_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 设置 matplotlib 支持中文
|
|
|
|
|
|
|
|
plt.rcParams['font.sans-serif'] = [font_prop.get_name()]
|
|
|
|
|
|
|
|
plt.rcParams['axes.unicode_minus'] = False
|
|
|
|
|
|
|
|
|
|
|
|
def log_print(message):
|
|
|
|
def log_print(message):
|
|
|
|
logging.info(message)
|
|
|
|
logging.info(message)
|
|
|
|
|