Libsvm中的决策值 [英] Decision values in Libsvm

查看:310
本文介绍了Libsvm中的决策值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SVM的新手.我将Libsvm用于Matlab,在预测阶段之后,我得到了一个决策值数组.根据SVM理论,如果

I'm new to SVM. I used Libsvm for Matlab, and after a prediction phase I've got a decision values array. From SVM theory: each test record z is assigned as positive if

f(z)= 1

f(z)=1

其中f(z)定义为

f(z)= sign(w * z + b)

f(z)=sign(w*z+b)

那么如何将实例z的数组中的决策值与f(z)相关联? 预测是否基于决策值:如果dec_value> 0,则z为正,否则z为负?

So how can I relate the decision value from the array for an instance z with f(z)? Is the prediction based on decision value so: if dec_value>0 then z is positive otherwise z is negative?

推荐答案

是的,您是正确的,如果f(z)是正数,则实例属于+1类,如果其负数则属于-1类. f(z)的值无法解释.

Yes, you are correct, if f(z) is positive, then the instance belongs to class +1, if its negative it belongs to class -1. The value of f(z) is not interpretable.

函数:

f(z)=符号(w * z + b)

f(z) = sign(w*z+b)

看起来像一个超平面方程,它的不同之处在于w不是法线向量-它的长度不是1,所以f(z)的值不是到超平面的距离,这就是为什么要指定它的原因以sign(..)表示,该值仅用于确定实例落在超平面的哪一侧.

looks like an equation for a hyperplane, it differs in that w is not a normal vector - its length is not 1, so the value of f(z) is not the distance from the hyperplane, this is why it is specified as sign(..), to make it clear the value is only used to determine which side of the hyperplane the instance falls on.

某些背景:

目标是找到能在两个类别之间提供最大余量的超平面:

The goal is to find the hyperplane which gives the maximum margin between the two classes:

因此,目的是使页边距最大化,即,从而将.请记住,通常使用 w 将超平面表示为法线向量时,是1.这里显然不是这种情况,因为不会有优化问题.而不是保持 = 1并更改页边距的宽度,而是将页边距的宽度固定为2并允许更改大小.

So, the purpose is to maximize the margin, which is , therefore minimizing . Remember, usually when w is used to represent a hyperplane as the normal vector, is 1. That isn't the case here clearly, as there would be no optimization problem. Instead of keeping = 1 and varying the width of the margin, we've fixed the width of the margin to 2 and are allowing to vary in size instead.

这为我们提供了主要优化问题(带有软边距):

This gives us the primal optimization problem (with soft margins):

这似乎就是您所指的.但是,该等式来自基本的软最大余量分类器,它是SVM的基础. True SVM表示为拉格朗日对偶,以允许使用内核.关于SVM的整洁之处在于,当在拉格朗日公式中表达上述问题(及其约束)时,除拉格朗日乘数之外的所有变量都消失了,这给我们带来了以下问题:

This seems to be what you are referring to. However, this equation comes from basic soft maximum margin classifier, which is foundation of SVM. True SVM is formulated as a Lagrangian dual to allow the use of kernels. The neat thing about SVM is that when the above problem (and its constraints) are formulated in the Lagrangian, all the variables except for the lagrangian multipliers drop out, leaving us with the following problem:

请注意,没有 w .训练点 x ( y 是标签1或-1),现在仅以点积形式出现,使我们可以使用

Notice there is no w. The training points x (y are the labels, 1 or -1), now only appear together as a dot product, allowing us to employ the kernel trick to obtain a non-linear model.

但是,如果我们没有 w ,我们的决策功能是什么?它成为我们的支持向量和我们发现的拉格朗日乘数的函数.

But if we don't have w what is our decision function? It becomes a function of our support vectors and the lagrangian multipliers we found.

这是libsvm生成的内容,并将其存储为您训练的模型.它存储支持向量和关联的alpha.对于线性SVM,您可以获取原始 w

This is what libsvm produces and what it stores as the model you have trained. It stores the support vectors and the associated alphas. For linear SVM, you can obtain the primal w, this is explained here in the LibSVM FAQ, but it is not going to be what you get back automatically from LibSVM, and this can only be done for the linear kernel.

基于拉格朗日乘数和支持向量的SVM决策函数的值也应仅通过其符号来解释.

The value of the SVM decision function based on the lagrangian multipliers and support vectors should only be interpreted by its sign as well.

这篇关于Libsvm中的决策值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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