matlab聚类算法综合F1值计算
其中A对应混淆矩阵
clc
clear all
% 输入1、2、3选择不同算法,具体顺序如下
x = input('please input a number:');
if x == 1
A = [10 0; 0 10];
elseif x == 2
A = [7 3; 2 8];
elseif x == 3
A = [5 5; 4 6];
end
ni = []; nj = []; nij = [];
for i = 1:2
ni = [ni, sum(A(i,:))];
nj = [nj, sum(A(:,i))];
for j = 1:2
nij = [nij, A(i,j)];
end
end
R11 = nij(1,1)/ni(1,1); R12 = nij(1,2)/ni(1,1);
R21 = nij(1,3)/ni(1,2); R22 = nij(1,4)/ni(1,2);
P11 = nij
共有 0 条评论