导航:首页 > 编程语言 > 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矩阵绘图相关的资料

热点内容
排课走班源码 浏览:222
程序员刚毕业去了小公司有发展吗 浏览:90
速腾怎么安装安卓手机互联 浏览:143
linux设备驱动程序代码 浏览:301
服务器的功耗怎么看 浏览:651
app组件哪里找 浏览:87
androidqq红包 浏览:412
服务器如何传输 浏览:456
如何快速将多个文件夹快速解压缩 浏览:114
程序员睡前都在想什么 浏览:37
少儿编程技能培训心得 浏览:458
白命令 浏览:816
headfirstjavapdf 浏览:552
广数980t怎么编程 浏览:592
无邪app在哪里下载 浏览:462
mac自带php目录 浏览:632
海淘小程序源码 浏览:750
哪里下载苏宁秒达app 浏览:643
androidcmnet 浏览:31
易语言标题源码 浏览:948