Predicting Mortality of ICU Patients: The PhysioNet/Computing in Cardiology Challenge 2012 1.0.0
(3,253 bytes)
function analyze_2d(data1,data2,IHD,ALL_CATEGORIES)
data2=abs(data2);
% plots data1 vs data2 pairs and sample mean and covariance
num_params=size(data1,2);
for param_idx=1:num_params
% mean_all=MEAN_DATA_ALL(:,param_idx);
% mean_1=MEAN_DATA_ALL(IHD==1,param_idx);
% mean_0=MEAN_DATA_ALL(IHD==0,param_idx);
%
%
% isnan1=sum(~isnan(MEAN_DATA_ALL(IHD==1,param_idx)))/(sum(IHD==1));
% isnan0=sum(~isnan(MEAN_DATA_ALL(IHD==0,param_idx)))/(sum(IHD==0));
%
% M1 = mode(mean_1);
% M0 = mode(mean_0);
% figure(param_idx)
%
% subplot(1,3,1)
% hist(mean_all)
% title([ALL_CATEGORIES{param_idx} ' all'])
%
%
% subplot(1,3,2)
% hist(mean_1)
% title([ALL_CATEGORIES{param_idx} ' 1'])
%
%
% subplot(1,3,3)
% hist(mean_0)
% title([ALL_CATEGORIES{param_idx} ' 0'])
% figure(param_idx+num_params+5)
% hist(mean_1,20)
% h = findobj(gca,'Type','patch');
% set(h,'FaceColor','r','EdgeColor','w','facealpha',0.75)
% hold on;
% hist(mean_0,20)
% h1 = findobj(gca,'Type','patch');
% set(h1,'facealpha',0.75);
% title([ALL_CATEGORIES{param_idx} ' mode0=' num2str(M0) '. ' ' mode1=' num2str(M1)]);
%
%
IHD2=IHD(~isnan(data1(:,param_idx)) & ~isnan(data2(:,param_idx)));
x=data1(~isnan(data1(:,param_idx)) & ~isnan(data2(:,param_idx)),param_idx);
mx0=mean(x(IHD2==0));
mx1=mean(x(IHD2==1));
y=data2(~isnan(data1(:,param_idx)) & ~isnan(data2(:,param_idx)),param_idx);
my0=mean(y(IHD2==0));
my1=mean(y(IHD2==1));
C0=cov(x(IHD2==0),y(IHD2==0));
eig(C0)
[pc1,score1,latent1,tsquare1] = princomp([x(IHD2==0) y(IHD2==0)]);
C1=cov(x(IHD2==1),y(IHD2==1));
[pc2,score2,latent2,tsquare2] = princomp([x(IHD2==1) y(IHD2==1)]);
figure(param_idx+num_params+5)
% scatter(data1(IHD==0,param_idx),data2(IHD==0,param_idx),'xr')
% hold on
% scatter(data1(IHD==1,param_idx),data2(IHD==1,param_idx),'ob')
scatter(x(IHD2==0),y(IHD2==0),'bx')
hold on
scatter(mx0,my0,'LineWidth',2,'MarkerEdgeColor','g')
CosTheta = dot(pc1(:,1),[1 0]')/(norm(pc1(:,1))*norm([1 0]'));
phi = acos(CosTheta);
% pdeellip(mx0,my0,latent(1),latent(2),phi)
h=ellipse(latent1(1),latent1(2),phi,mx0,my0,'b');
scatter(x(IHD2==1),y(IHD2==1),'rx')
scatter(mx1,my1,'LineWidth',2,'MarkerEdgeColor','g')
CosTheta = dot(pc2(:,1),[1 0]')/(norm(pc2(:,1))*norm([1 0]'));
phi = acos(CosTheta);
% pdeellip(mx0,my0,latent(1),latent(2),phi)
h=ellipse(latent1(1),latent1(2),phi,mx1,my1,'r');
title([ALL_CATEGORIES{param_idx}]);
% data = rand(1, 100);
% [N, X] = hist(data, 0:0.1:1);
%
% subplot(2, 1, 1);
% hist(data, 0:0.1:1);
%
% subplot(2, 1, 2);
% bar(X, N./sum(N), 1);
end
end