How to label the training projections obtained by PCA to use for training SVM for classification? MATLAB

前端 未结 3 757
清歌不尽
清歌不尽 2020-12-20 03:11

I have a \"training set\" of images. I have formed the \'Eigenspace\'. Now i need to label the projections to train the SVM. The projections of \"face 1\" to the Eigenspace

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 03:58

    If you are trying to recognize more than one person, you have to create one separate data file for each person, and one sepparate SVM for each person. This is because SVM are focused on two-class separation.

    This is an example using libsvm for Matlab (here is the full code), supposing you have the data in a file:

    [person1_label, person1_inst] = libsvmread('../person1');
    [person2_label, person2_inst] = libsvmread('../person2');
    [person3_label, person3_inst] = libsvmread('../person3');
    
    model1 = svmtrain(person1_label, person1_inst, '-c 1 -g 0.07 -b 1');
    model2 = svmtrain(person2_label, person2_inst, '-c 1 -g 0.07 -b 1');
    model3 = svmtrain(person3_label, person3_inst, '-c 1 -g 0.07 -b 1');
    

    To test one face, you need to apply all the models and get the max output (when using svmpredict you have to use '-b 1' to obtain the probability estimates.

    Additionally, in Matlab you don't need to use svmread or svmwrite, you can pass directly the data:

    training_data = [];%Your matrix that contains 4 feature vectors
    person1_label =[1,1,-1,-1];
    person2_label = [-1,-1,1,-1];
    person3_label = [-1,-1,-1,1];
    
    model1 = svmtrain(person1_label, person_inst, '-c 1 -g 0.07 -b 1');
    model2 = svmtrain(person2_label, person_inst, '-c 1 -g 0.07 -b 1');
    model3 = svmtrain(person3_label, person_inst, '-c 1 -g 0.07 -b 1');
    

提交回复
热议问题