Skip to content

Commit c2fd66f

Browse files
committed
Changed step 3 to do LOOCV using standard dLDA
1 parent 58bbcc6 commit c2fd66f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

rdpg/analysis.m

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
singVals(:,k) = diag(squeeze(Ss(:,:,k)));
4949
end
5050

51-
5251
% show scree plots of for all the graphs, red is targs is true blue is
5352
% targs is false
5453
figure(401);
@@ -59,10 +58,22 @@
5958
%% Step 3 - Classify using first d singular values
6059
% needed to add the repo to the path
6160
d=5;
62-
inds = struct('ytrn', 1:length(targs),...
63-
'y0trn', find(targs == 0),...
64-
'y1trn', find(targs == 1));
61+
n=length(targs);
62+
all_ind = struct('ytrn', 1:n,'y0trn', find(targs == 0), 'y1trn', find(targs == 1));
63+
ind = struct('ytrn', cell(n,1),'y0trn', cell(n,1),'y1trn', cell(n,1));
64+
6565
discrim = struct('dLDA',1);
66-
params = get_discriminant_params(singVals(1:d,:),inds,discrim);
66+
Lhat = struct('dLDA',cell(n,1));
67+
Lsem = Lhat;
68+
% remove each sample to do LOOCV
69+
for k=1:n
70+
ind(k).ytrn = all_ind.ytrn(all_ind.ytrn~=k);
71+
ind(k).y0trn = all_ind.y0trn(all_ind.y0trn~=k);
72+
ind(k).y1trn = all_ind.y1trn(all_ind.y1trn~=k);
73+
params = get_discriminant_params(singVals(1:d,:),...
74+
inds(k),discrim);
75+
[Lhat(k) Lsem(k)] = discriminant_classifiers(singVals(1:d,k),targs(k),...
76+
params,discrim);
77+
end
78+
6779

68-
[Lhat Lsem] = discriminant_classifiers(singVals(1:d,:),targs,params,discrim);

0 commit comments

Comments
 (0)