48
48
singVals(: ,k ) = diag(squeeze(Ss(: ,: ,k )));
49
49
end
50
50
51
-
52
51
% show scree plots of for all the graphs, red is targs is true blue is
53
52
% targs is false
54
53
figure(401 );
59
58
%% Step 3 - Classify using first d singular values
60
59
% needed to add the repo to the path
61
60
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
+
65
65
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
+
67
79
68
- [Lhat Lsem ] = discriminant_classifiers(singVals(1 : d ,: ),targs ,params ,discrim );
0 commit comments