python?離散點(diǎn)圖畫法的實(shí)現(xiàn)
基礎(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ù)測(cè)值") 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ù)測(cè)值") axes.set_title("矯正網(wǎng)絡(luò)預(yù)測(cè)結(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ù)測(cè)值") axes.set_title("矯正網(wǎng)絡(luò)預(yù)測(cè)結(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ù)測(cè)值") axes.set_title("矯正網(wǎng)絡(luò)預(yù)測(cè)結(jié)果") axes.set_ylim((36, 37)) plt.savefig("result.png") plt.legend(['真實(shí)值36.7℃', '預(yù)測(cè)值'], 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ù)測(cè)值") axes.set_title("矯正網(wǎng)絡(luò)預(yù)測(cè)結(jié)果") axes.set_ylim((36, 37)) plt.savefig("result.png") plt.legend(['真實(shí)值36.7℃', '預(yù)測(cè)值'], 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 離散點(diǎn)圖畫法的文章就介紹到這了,更多相關(guān)python 離散點(diǎn)圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python函數(shù)參數(shù)中的*與**運(yùn)算符
這篇文章主要介紹了Python函數(shù)參數(shù)中的*與**運(yùn)算符,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04WIndows10系統(tǒng)下面安裝Anaconda、Pycharm及Pytorch環(huán)境全過程(NVIDIA?GPU版本)
這篇文章主要給大家介紹了關(guān)于WIndows10系統(tǒng)下面安裝Anaconda、Pycharm及Pytorch環(huán)境(NVIDIA?GPU版本)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-02-02python爬取網(wǎng)易云音樂熱歌榜實(shí)例代碼
在本篇文章里小編給大家整理的是關(guān)于python爬取網(wǎng)易云音樂熱歌榜實(shí)例代碼,需要的朋友們可以學(xué)習(xí)下。2020-08-08基于python3.7利用Motor來異步讀寫Mongodb提高效率(推薦)
Motor是一個(gè)異步mongodb driver,支持異步讀寫mongodb。它通常用在基于Tornado的異步web服務(wù)器中。這篇文章主要介紹了基于python3.7利用Motor來異步讀寫Mongodb提高效率,需要的朋友可以參考下2020-04-04Python中的 any() 函數(shù)和 all() 函數(shù)
這篇文章主要介紹了Python中的 any() 函數(shù)和 all() 函數(shù),文章基于Python的相關(guān)資料展開對(duì) any 和 all() 函數(shù)的語法詳細(xì)內(nèi)容,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-04-04python微信公眾號(hào)之關(guān)鍵詞自動(dòng)回復(fù)
這篇文章主要為大家詳細(xì)介紹了python微信公眾號(hào)之關(guān)鍵詞自動(dòng)回復(fù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06pytorch中的weight-initilzation用法
這篇文章主要介紹了pytorch中的weight-initilzation用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-06-06詳解用Python實(shí)現(xiàn)自動(dòng)化監(jiān)控遠(yuǎn)程服務(wù)器
這篇文章主要介紹了用Python實(shí)現(xiàn)自動(dòng)化監(jiān)控遠(yuǎn)程服務(wù)器,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05Ubuntu 下 vim 搭建python 環(huán)境 配置
這篇文章主要介紹了Ubuntu 下 vim 搭建python環(huán)境配置,需要的朋友可以參考下2017-06-06