range_ = 1.5
compare_line = list(np.arange(-range_,range_,0.01))
font_size = 16
plt.rcParams['font.family'] = 'SimHei'
plt.rcParams['font.size'] = font_size
plt.rcParams['axes.unicode_minus'] = False
# 测试集
plt.figure(figsize=(8,6))
plt.scatter(pred_test_y, test_y, color='r')
plt.plot(compare_line, compare_line, '--')
plt.xlim([-range_, range_])
plt.ylim([-range_, range_])
plt.xticks(fontproperties='SimHei', size=font_size)
plt.yticks(fontproperties='SimHei', size=font_size)
plt.xlabel('预测值',size=font_size)
plt.ylabel('实际值',size=font_size)
plt.savefig("./测试集结果.png")
# plt.show()
plt.close()
# 训练集
pred_y = model.predict(X)
plt.figure(figsize=(8,6))
plt.scatter(pred_y, y, color='r')
plt.plot(compare_line, compare_line, '--')
range_ = 1.5
plt.xlim([-range_, range_])
plt.ylim([-range_, range_])
plt.xticks(fontproperties='SimHei', size=font_size)
plt.yticks(fontproperties='SimHei', size=font_size)
plt.xlabel('预测值',size=font_size)
plt.ylabel('实际值',size=font_size)
plt.savefig("./训练集结果.png")
# plt.show()
plt.close()
matplotlib快速画图
最新推荐文章于 2023-08-25 09:59:09 发布