首页 > 编程知识 正文

清晰集定性比较分析,混淆矩阵计算灵敏度

时间:2023-05-04 15:39:27 阅读:114524 作者:1858

真定位(TP ) :实际上是正示例,并且被预测为正示例

FP (假定位) :实际上是反例,但被预测为正例

真否定(TN ) :实际上是反例,并且被预测为反例

fn (假否定) :实际上是正的,但被预测为反的

准确率=TP/(TPFP ) ) )。

召回率=TP/(TPfn ) )。

# coding=utf-8 importmatplotlib.pyplotaspltimportnumpyasnpconfusion=NP.array (0,0 ),[ 0,0,200,0,0,0,0,0,0,0,0,0,0,0 0 ] 0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 200] ) classes=['1'、'2'、'3'、'4'、'5'、'6'、'7'、'8'、'9'、' 10 '、' 11 ' ] )。 其他不同颜色的PLT.imshow(confmatrix, 可以设置cmap=plt.cm.Blues ) # ticks坐标轴的坐标点# label坐标轴标签说明indices=range(len ) confmatrix )。第二个参数是坐标轴显示列表# PLT.x [ 0,1,2 ] ) PLT.x ticks indices, 作为classes )的classes.PLT.color bar (PLT.xlabel预测值) plt.ylabel真值) (plt.title混淆矩阵) # plt.rcParams两行是PLT.rcparams [ ' axes.unicode _ MINUS ' ]=false #显示数据for first _ indexinrange (len (conf matrix ) )第几行的forsecond _显示数据第几列if first _ index==second _ index 3360 PLT conf matrix [ first _ index ] [ second _ index ],va='center ',ha=' cecex color='white ' ) else 3360 PLT.text ext conf matrix [ first _ index ] [ second _ index ],va='center ', 在ha='center ' ) matlab中直接针对矩阵使用imagesc(confusion ) plt.show ) # 可以显示计算精度defcalculate_all_prediction ) confmatrix ) 30的对角线上的所有值总计: return : ' ' total _ sum=conf matrix.ssurix float(total_sum )是, 2 )计算每个print (精度:(str(prediction ) % ) defcalculae _ lable _ prediction (conf matrix ) 3360 ) )类别的预测精度: sum(axis=1) [ I ] label _ correct _ sum=conf矩阵[ I ] ) ) ) 65浮动(label _ correct _ sum )/2 )打印(准确率: ) classes [ I ] (: ) str (prediction ) % ) ) def calculate _ label _ recall (conf matrix ) 33666 label _ correct _ sum=conf matrix [ I ] [ I ] prediction=loat (label _ total _ sum )表示2 ) print (召回率: (class

E:Anaconda python.exe ' e :/classficationofnetwork/z.other/模糊矩阵. py '准确率:1:100.0%准确率:2:100.0%准确率:100.0 %准确率:4:99.5%准确率:5:100.0 %准确率:633606 度率:9:100.0%准确率:10:99.5%准确率:100.0%准确率:123:99.5 %准确率:13:98.5%准确率60100.0 %召回率6099.5%召回率:100.0 %召回率:4:100.0%召回率:5:100.0 %召回率:63363600.0%召回率33363600 33600 33606 召回率:10:100.0 %召回率:11:100.0%召回率:12:100.0 %召回率:13360100.0 %

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