I am currently doing a project on multimodal biometrics (fusion at score level). So I need to get the score before fusion. Can anyone tell me how to get the score of the particular test sample using a trained SVM classifier?
I have used the inbuilt svmtrain
and svmclassify
functions in MATLAB.
Unfortunately the
svmclassify
function only outputs the label of the class and no distance (score). You will have to write your own classification function. Luckily, this is very easy: As you do have the Statistics Toolbox withsvmclassify
, you can easily look at the source code of the function withYou will see that most of the function is checking inputs etc. The important parts are scaling the data:
and doing the classification using a built-in function
svmdecision
:From the definition of
svmdecision
you will see that it outputs the distancef
, butsvmclassify
ignores it. You could therefore easily create a new function, which looks almost exactly likesvmclassify
, but also returnsf
:You will find that
svmdecision
is a private function. To be able to call it from your function, you have to make a copy in your local folder (or any subfolder).