日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

python?離散點(diǎn)圖畫法的實(shí)現(xiàn)_python

作者:心之所向521 ? 更新時(shí)間: 2022-06-02 編程語言

基礎(chǔ)代碼

pred_y = test_output.data.numpy()
pred_y = pred_y.flatten()
print(pred_y, 'prediction number')
print(test_y[:355].numpy(), 'real number')
?
import matplotlib.pyplot as plt
plt.rc("font", family='KaiTi')
plt.figure()
f, axes = plt.subplots(1, 1)
x = np.arange(1, 356)
# axes.plot(x , pred_y)
axes.scatter(x,pred_y, c='r', marker = 'o')
plt.axhline(36.7, c ='g')
axes.set_xlabel("位置點(diǎn)位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)結(jié)果")
plt.savefig("result.png")
plt.show()

離散圖畫法如上所示。

改進(jìn)

import matplotlib.pyplot as plt
plt.rc("font", family='KaiTi')
plt.figure()
f, axes = plt.subplots(1, 1)
x = np.arange(1, 356)
# axes.plot(x , pred_y)
axes.scatter(x, pred_y, c='r', marker = 'o')
plt.axhline(36.7, c ='g')
axes.set_xlabel("位置點(diǎn)位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)預(yù)測結(jié)果")
axes.set_ylim((36, 37))
plt.savefig("result.png")
plt.show()

再次改進(jìn):

import matplotlib.pyplot as plt
plt.rc("font", family='KaiTi')
plt.figure()
f, axes = plt.subplots(1, 1)
x = np.arange(1, 356)
# axes.plot(x , pred_y)
axes.scatter(x, pred_y, c='r', marker = 'o')
plt.axhline(36.7, c ='g')
axes.set_xlabel("位置點(diǎn)位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)預(yù)測結(jié)果")
axes.set_ylim((36, 37))
plt.savefig("result.png")
plt.legend(['real', 'predict'], loc='upper left')
plt.show()

又次改進(jìn):

import matplotlib.pyplot as plt
plt.rc("font", family='KaiTi')
plt.figure()
f, axes = plt.subplots(1, 1)
x = np.arange(1, 356)
# axes.plot(x , pred_y)
axes.scatter(x, pred_y, c='r', s=3, marker = 'o')
plt.axhline(36.7, c ='g')
axes.set_xlabel("位置點(diǎn)位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)預(yù)測結(jié)果")
axes.set_ylim((36, 37))
plt.savefig("result.png")
plt.legend(['真實(shí)值36.7℃', '預(yù)測值'], loc='upper left')
plt.show()

改進(jìn):----加準(zhǔn)確率

import matplotlib.pyplot as plt
plt.rc("font", family='KaiTi')
plt.figure()
f, axes = plt.subplots(1, 1)
x = np.arange(1, 356)
# axes.plot(x , pred_y)
axes.scatter(x, pred_y, c='r', s=3, marker = 'o')
plt.axhline(36.7, c ='g')
axes.set_xlabel("位置點(diǎn)位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)預(yù)測結(jié)果")
axes.set_ylim((36, 37))
plt.savefig("result.png")
plt.legend(['真實(shí)值36.7℃', '預(yù)測值'], loc='upper left')
?
row_labels = ['準(zhǔn)確率:']
col_labels = ['數(shù)值']
table_vals = [['{:.2f}%'.format(v*100)]]
row_colors = ['gold']
my_table = plt.table(cellText=table_vals, colWidths=[0.1] * 5,
                             rowLabels=row_labels, rowColours=row_colors, loc='best')
plt.show()

原文鏈接:https://blog.csdn.net/weixin_45564943/article/details/123880105

欄目分類
最近更新