% what do the simple approaches give?
load cellssimplemax;
%load cells_lbp_gauss3; gencellsimple
xtrain = a; xtest = b;
a = [a;b];

%% add the different orientations...
%b = a(:,1);
%for i=0:7
%   I = 1+((i*4):(i*4+3));
%   b = [b mean(a(:,I),2)];
%end
%b = a;
%a = a(:,[1:5]);


% param:
%u = scalem([],'variance')*knnc([],1);
%u = fisherm([],4)*knnc;
%u = scalem([],'variance')*parzenc;
%u = fisherc;
%u = ldc;
u = scalem([],'variance')*libsvc;

% train and test:
w = xtrain*u;
error_on_testset = xtest*w*testd


% crossval on a:
imlab = getident(a,'image');
[nlab,baglab] = renumlab(imlab);
nrfolds = length(baglab); % leave one image out

e = zeros(nrfolds,1);
Iall = (1:size(nlab,1))';

for i=1:nrfolds
   Jtst = find(nlab==i);
   Jtrn = Iall; Jtrn(Jtst)=[];

   x = a(Jtrn,:);
   z = a(Jtst,:);
%   f(i) = find(classsizes(z)>0)

   w = x*u;
   e(i,1) = z*w*testd;
end
e
mean(e)
error_on_testset 


