Matlab code example to generate some data a hypothetical scenario
Applications: sensitivity (true positive rate) and specificity (true negative rate) analysis In medical diagnosis and equipment test, sensitivity is a test of correctly identify those with the disease. specificity is a test of correctly identify those without the disease.
Contents
close
close all;
clear;
clc;
clf;
subplot(211);
M1 = 20;
c1 = [0.2,0.2];
x1 = randn(M1,1)+c1(1);
y1 = randn(M1,1)+c1(2);
h1 = line(x1,y1,'linestyle','none','marker','o','DisplayName','normal');
line(c1(1),c1(2),'marker','x','color','b','markersize',12);
M2 = 20;
c2 = [2, 3];
x2 = randn(M2,1)+c2(1);
y2 = randn(M2,1)+c2(2);
h2 = line(x2,y2,'linestyle','none','marker','^','color','r','DisplayName','atrial tach');
line(c2(1),c2(2),'marker','x','color','r','markersize',12);
xlim([-3,5]);
ylim([-3,7]);
legend([h1, h2]);
xlabel('\propto Heart rate');
ylabel('\propto P-R interval');
title('Hypothetical classification data');
perform linear classification
X = [x1, y1, ones(M1,1); x2, y2, ones(M2,1)];
d = [repmat(0,[M1,1]); repmat(1,[M2,1])];
subplot(212);
plot(X(:,1),X(:,2),'o');
xlim([-3,5]);
ylim([-3,7]);
w = inv(X.' * X) * X.' * d;
xx = linspace(min(xlim()), max(xlim()), 64);
yy = -w(1)/w(2)*xx - (w(3)-0.5)/w(2);
line(xx,yy,'color','k');
Apply classifier to the data
d_out = X*w>0.5;
figure;
cla
line(X((d_out==0),1), X((d_out==0),2),'marker','o','color','b','linestyle','none');
line(X((d_out==1),1), X((d_out==1),2),'marker','^','color','r','linestyle','none');
line(xx,yy,'color','k');
xlim([-3,5]);
ylim([-3,7]);
title('classifier output');
No comments:
Post a Comment