python?離散點圖畫法的實現(xiàn)
更新時間:2022年04月01日 10:33:55 作者:心之所向521
本文主要介紹了python?離散點圖畫法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
基礎(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("位置點位")
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("位置點位")
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("位置點位")
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("位置點位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)預(yù)測結(jié)果")
axes.set_ylim((36, 37))
plt.savefig("result.png")
plt.legend(['真實值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("位置點位")
axes.set_ylabel("預(yù)測值")
axes.set_title("矯正網(wǎng)絡(luò)預(yù)測結(jié)果")
axes.set_ylim((36, 37))
plt.savefig("result.png")
plt.legend(['真實值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()到此這篇關(guān)于python 離散點圖畫法的文章就介紹到這了,更多相關(guān)python 離散點圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Tensorflow中tf.ConfigProto()的用法詳解
今天小編就為大家分享一篇Tensorflow中tf.ConfigProto()的用法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02
關(guān)于pygame自定義窗口創(chuàng)建及相關(guān)操作指南
對于開發(fā)一個游戲來說,窗口的顯示肯定是前提中的前提,對于pygame來說,只需要一小段代碼就可以初始化窗口,下面這篇文章主要給大家介紹了關(guān)于pygame自定義窗口創(chuàng)建及相關(guān)操作的相關(guān)資料,需要的朋友可以參考下2022-07-07
Python開發(fā)網(wǎng)站目錄掃描器的實現(xiàn)
這篇文章主要介紹了Python開發(fā)網(wǎng)站目錄掃描器的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-02-02
jupyter notebook 的工作空間設(shè)置操作
這篇文章主要介紹了jupyter notebook 的工作空間設(shè)置操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
PyPDF2讀取PDF文件內(nèi)容保存到本地TXT實例
這篇文章主要介紹了PyPDF2讀取PDF文件內(nèi)容保存到本地TXT實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05

