如何在MATLAB中找到SVM分类器的分数? [英] How to find the score of a SVM classifier in MATLAB?

查看:229
本文介绍了如何在MATLAB中找到SVM分类器的分数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在做一个有关多模式生物特征识别(分数水平融合)的项目.所以我需要在融合之前得到分数. 谁能告诉我如何使用训练有素的SVM分类器获得特定测试样本的分数?

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?

我已经在MATLAB中使用了内置的svmtrainsvmclassify函数.

I have used the inbuilt svmtrain and svmclassify functions in MATLAB.

推荐答案

不幸的是,svmclassify函数仅输出该类的标签,而不会输出距离(分数).您将必须编写自己的分类函数.幸运的是,这非常简单:当您拥有带有svmclassify的Statistics Toolbox时,您可以使用

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 with svmclassify, you can easily look at the source code of the function with

edit svmclassify

您将看到大多数功能正在检查输入等.重要部分是缩放数据:

You will see that most of the function is checking inputs etc. The important parts are scaling the data:

sample(:,c) = svmStruct.ScaleData.scaleFactor(c) * ...
              (sample(:,c) +  svmStruct.ScaleData.shift(c));

并使用内置函数svmdecision进行分类:

and doing the classification using a built-in function svmdecision:

outclass = svmdecision(sample,svmStruct);

根据svmdecision的定义,您将看到它输出了距离f,但是svmclassify忽略了它.因此,您可以轻松地创建一个新函数,该函数看上去几乎与相似,而且返回f:

From the definition of svmdecision you will see that it outputs the distance f, but svmclassify ignores it. You could therefore easily create a new function, which looks almost exactly like svmclassify, but also returns f:

1   function [outclass,f] = svmclassify(svmStruct,sample, varargin)
...
112    [outclass,f] = svmdecision(sample,svmStruct);
...
158    outclass = []; f = [];

您会发现svmdecision私有功能.为了能够从函数中调用它,您必须在本地文件夹(或任何子文件夹)中进行复制.

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).

这篇关于如何在MATLAB中找到SVM分类器的分数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆