根据值画颜色

import sklearn.metrics
import matplotlib.pyplot as plt
import numpy as np
import torch

confusion_matrix = torch.tensor([0.8225, 0.8302, 0.8374, 0.8361, 0.4787, 0.832, 0.8324, 0.8415, 0.841, 0.4332, 0.8352,
                                 0.8394, 0.8374, 0.8377, 0.422, 0.8272, 0.8307, 0.8392, 0.8404, 0.4478, 0.4536, 0.4312,
                                 0.4233, 0.4337, 0.6849])
confusion_matrix = confusion_matrix.reshape(5,5)
confusion_matrix = confusion_matrix*100


fig, axes = plt.subplots(1)
plt.imshow(confusion_matrix, cmap='Blues')
class_names = [0.2, 0.4, 0.6, 0.8, 1.0]
plt.title('Cora')
axes.set_xticks([i for i in range(len(class_names))])
axes.set_yticks([i for i in range(len(class_names))])
axes.set_xticklabels(class_names, ha='right', fontsize=8, rotation=40)
axes.set_yticklabels(class_names, ha='right', fontsize=8)

for (i, j), z in np.ndenumerate(confusion_matrix):
    axes.text(j, i, '%.2f' % z, ha='center', va='center', color='black', fontsize=12)

plt.tight_layout()


plt.show()
plt.close()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值