導航:首頁 > 編程語言 > python矩陣繪圖

python矩陣繪圖

發布時間:2025-01-17 16:17:10

python 編程,繪圖與矩陣,詳細在圖里,求代碼,急用

import numpy as np

a=np.mat('-1,4,0;3,4,-4;-10,-12,5')

b=np.mat('-72;-4;-50')

c=np.linalg.solve(a,b)

print(c)

Ⅱ python是否有繪制混淆矩陣的函數,怎麼來實現

#-*-coding:UTF-8-*-
"""繪制混淆矩陣圖"""
importmatplotlib.pyplotasplt
fromsklearn.metricsimportconfusion_matrix


defconfusion_matrix_plot_matplotlib(y_truth,y_predict,cmap=plt.cm.Blues):
"""Matplotlib繪制混淆矩陣圖
parameters
----------
y_truth:真實的y的值,1darray
y_predict:預測的y的值,1darray
cmap:畫混淆矩陣圖的配色風格,使用cm.Blues,更多風格請參考官網
"""
cm=confusion_matrix(y_truth,y_predict)
plt.matshow(cm,cmap=cmap)#混淆矩陣圖
plt.colorbar()#顏色標簽

forxinrange(len(cm)):#數據標簽
foryinrange(len(cm)):
plt.annotate(cm[x,y],xy=(x,y),horizontalalignment='center',verticalalignment='center')

plt.ylabel('Truelabel')#坐標軸標簽
plt.xlabel('Predictedlabel')#坐標軸標簽
plt.show()#顯示作圖結果


if__name__=='__main__':
y_truth=[1,0,1,1,1,1,1,1,1,1,0,0,0,0,0]
y_predict=[1,0,0,1,0,1,1,1,1,1,0,1,0,1,0]
confusion_matrix_plot_matplotlib(y_truth,y_predict)

Ⅲ 如何使用python表示矩陣

使用python表示矩陣的方法:

使用「import numpy」語句導入numpy包。用numpy包的array函數創建一個二維數組,這個二維數組就表示矩陣

示例代碼如下:

執行結果如下:

閱讀全文

與python矩陣繪圖相關的資料

熱點內容
python語料訓練 瀏覽:338
武夷岩茶產地溯源碼 瀏覽:383
求生組隊用什麼伺服器最好 瀏覽:24
php回調匿名回調函數 瀏覽:107
源碼翻譯軟體哪裡找 瀏覽:523
邪惡程序員解說 瀏覽:600
醫生找程序員 瀏覽:423
cad三維剖切命令 瀏覽:55
壓縮機的氣能流多遠 瀏覽:85
linuxfdiskt 瀏覽:696
iphone沒有id怎麼用app 瀏覽:983
手機淘寶網站源碼 瀏覽:743
小車上的壓縮機怎麼改氣泵 瀏覽:568
免費雲伺服器任務 瀏覽:211
蘋果怎樣在手機上做壓縮文件 瀏覽:644
如何搭建sslvpn伺服器 瀏覽:33
php鏡像程序 瀏覽:7
linux變數命名 瀏覽:157
phppdf轉換為圖片 瀏覽:374
聊天室源碼完整版 瀏覽:588