function [ pred ] = pniClassifyD(xtest) %PNINIC Nic's initial entry % [ pred ] = pniNic(data) calculates a mortality prediction for each % each row (observation/subject) in data % % The score uses the following variables: % urine, platelets, BUN, creatinine, PaFi ratio, PaO2, PaCO2, pH, % heart_rate, temperature, BP, and age. % % Inputs: % data - Cell array of data. % Column 1 - Subject IDs % Column 2 - Time stamp vectors for each subject % Column 3 - Feature name vectors for each subject % Column 4 - Data value vectors for each subject % % Outputs: % pred - Column vector of predictions % % Example % %=== Load data in % load('data_processed_cell.mat'); % % %=== Calculate score % [ score ] = pniAndrew(data); % % See also PNMAIN PNPREPROCESSDATA % References: % Physionet Challenge 2012 % http://physionet.org/challenge/2012/ % % Copyright 2012 Alistair Johnson % $LastChangedBy: alistair $ % $LastChangedDate: 2012-04-25 01:26:50 +0100 (Wed, 25 Apr 2012) $ % $Revision: 344 $ % Originally written on GLNXA64 by Alistair Johnson, 15-Apr-2012 14:40:40 % Contact: alistairewj@gmail.com N = size(xtest,1); %=== Load original training data for relative ranking bart = load('FriendlyBARTPred_ALLDATA_202feats.mat','xtrain2','bigy','xtrain','dog'); xtrain = bart.xtrain; xtrain2 = bart.xtrain2; bigy = bart.bigy; dog = bart.dog; [d1,d2]=size(xtrain); %=== DEFAULTS goes=4000000; % # MCMC samples crag=40; trees=500; % # of trees width=1/5; % %This is making predictions for new data. Predictions are stored in testmo. bab=[xtest;xtrain2]; %=== Rank variables for i=1:d2 temp=tiedrank(bab(:,i)); mog=1:size(xtest,1); for j=mog(~isnan(temp(mog))) temp(temp==temp(j) & ~isnan(temp))=temp(temp==temp(j) & ~isnan(temp))-0.5; temp(temp>temp(j) & ~isnan(temp))=temp(temp>temp(j) & ~isnan(temp))-1; end xtest(:,i)=temp(1:size(xtest,1)); end testmo=zeros(size(xtest,1),1); ly=size(bigy,1); fprintf('Calculating probability...'); for i=1:ly temp=zeros(size(xtest,1),1); temp=temp+bigy(i,1,trees+1); for j=1:trees val=zeros(size(xtest,1),1); t7=bigy(i,:,j); s1=xtest(:,t7(1))>t7(4)*dog(t7(1)); if(t7(7)) s1(isnan(s1))=1; end if(t7(10)<3) s1=~s1; end s2=xtest(:,t7(2))>t7(5)*dog(t7(2)); if(t7(8)) s2(isnan(s2))=1; end if(mod(t7(10),2)==0) s2=~s2; end s1 = s1 & s2; s2 = s1 & isnan(xtest(:,t7(3))); s1 = s1 & ~isnan(xtest(:,t7(3))); x2=norminv(xtest(:,t7(3))/dog(t7(3))); val(s2) = t7(11) + t7(9); val(s1) = t7(11) + t7(6)*x2(s1); temp=temp+val; end testmo=testmo+1./(1+exp(-temp))/ly; % if mod(i,100)==0 % fprintf('%g%% complete.\n',round(100*i/ly)); % end end fprintf('... done.\n'); pred=testmo; end