I have extracted HOG features for male and female pictures, now, I'm trying to use the Leave-one-out-method to classify my data. Due the standard way to write it in Matlab is:
[Train, Test] = crossvalind('LeaveMOut', N, M);
What I should write instead of N and M?
Also, should I write above code statement inside or outside a loop?
this is my code, where I have training folder for Male (80 images) and female (80 images), and another one for testing (10 random images).
for i = 1:10
[Train, Test] = crossvalind('LeaveMOut', N, 1);
SVMStruct = svmtrain(Training_Set (Train), train_label (Train));
Gender = svmclassify(SVMStruct, Test_Set_MF (Test));
end
Notes:
Training_Set: an array consist of HOG features of training folder images.Test_Set_MF: an array consist of HOG features of test folder images.N: total number of images in training folder.- SVM should detect which images are male and which are female.
I will focus on how to use
crossvalindfor the leave-one-out-method.I assume you want to select random sets inside a loop.
Nis the length of your data vector.Mis the number of randomly selected observations inTest. RespectivelyMis the number of observations left out inTrain. This means you have to setNto the length of your training-set. WithMyou can specify how many values you want in yourTest-output, respectively you want to left out in yourTrain-output.Here is an example, selecting
M=2observations out of the dataset.This outputs: (this is generated randomly, so you won't have the same result)
As you have it in your code according to this post, you need to adjust it for a matrix of features: