I extracted the PCA functions using:
function [mn,A1,A2,Eigenfaces] = pca(T,f1,nf1) m=mean(T,2), %T is the whole training set train=size(T,2); A=[]; for i=1:train temp=double(T(:,i))-m; A=[A temp]; end train=size(f1,2); %f1 - Face 1 images from training set 'T' A=[]; for i=1:train temp=double(f1(:,i))-m; A1=[A1 temp]; end train=size(nf1,2); %nf1 - Images other than face 1 from training set 'T' A=[]; for i=1:train temp=double(nf1(:,i))-m; A2=[A2 temp]; end L=A'*A; [VD]=eig(L); for i=1:size(V,2) if(D(i,i)>1) L_eig=[L_eig V(:,1)]; end end Eigenfaces=A*L_eig; end
Then I projected only face 1 (grade +1) from the training data as such:
Function 1
for i=1:15 %number of images of face 1 in training set temp=Eigenfaces'*A1(:,i); proj_img1=[proj_img1 temp]; end
Then I project the rest of the faces (class -1) from the training data as such:
Function 2
for i=1:221 %number of images of faces other than face 1 in training set temp=Eigenfaces'*A2(:,i); proj_img2=[proj_img2 temp]; end
Function 3 Then, the input image vector was obtained using:
diff=double(inputimg)-mn; %mn is the mean of training data testfeaturevector=Eigenfaces'*diff;
I wrote the results of function 1 and 2 in a CSV file with labels +1 and -1, respectively. Then I used LIBSVM to get the accuracy when providing the true label, it returned 0%, and when I tried to predict the label, it was -1 instead of +1.
And accuracy is approaching like 0%?
Basically, my model is not trained properly, and I see no error.
Any suggestions would be highly appreciated.