首页 > 编程知识 正文

李摄像学笔记(25)——观看准确性、敏感性、特异性和混淆矩阵

时间:2023-05-05 13:51:17 阅读:252476 作者:176

本笔记来源于B站Up主: 有Li 的影像组学系列教学视频
本节(25)主要讲解: 通过sklearn包输出准确度、灵敏度、特异度及混淆矩阵

基本概念

代码实现 from sklearn.metrics import classification_reporty_pred = [0,1,0,1,0,0,1]y_true = [0,0,0,1,1,0,1]print(classification_report(y_true,y_pred))# 结果如下:# precision recall f1-score support# 0 0.75 0.75 0.75 4# 1 0.67 0.67 0.67 3# accuracy 0.71 7# macro avg 0.71 0.71 0.71 7# weighted avg 0.71 0.71 0.71 7 # 显示 confusion matrix# method 1from sklearn.metrics import confusion_matrixprint(confusion_matrix(y_true, y_pred))# [[3 1]# [1 2]] # method 2 (图形化输出)import matplotlib.pyplot as pltcm = confusion_matrix(y_true, y_pred)fig, ax = plt.subplots(figsize=(8, 8))ax.imshow(cm)ax.grid(False)ax.xaxis.set(ticks=(0, 1), ticklabels=('Predicted 0s', 'Predicted 1s'))ax.yaxis.set(ticks=(0, 1), ticklabels=('Actual 0s', 'Actual 1s'))ax.set_ylim(1.5, -0.5)for i in range(2): for j in range(2): ax.text(j, i, cm[i, j], ha='center', va='center', color='red')plt.show()

结果如图:

作者:北欧森林
链接:https://www.jianshu.com/p/347323b74d91
来源:简书,已获授权转载

RadiomicsWorld.com “影像组学世界”论坛:
影像组学世界/RadiomicsWorld

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。