svm

Matlab libsvm - how to find the w coefficients

ぃ、小莉子 提交于 2019-12-29 17:47:30
问题 How can find what the vector w is, i.e. the perpendicular to the separation plane? 回答1: This is how I did it here. If I remember correctly, this is based on how the dual form of the SVM optimisation works out. model = svmtrain(...); w = (model.sv_coef' * full(model.SVs)); And the bias is (and I don't really remember why its negative): bias = -model.rho; Then to do the classification (for a linear SVM), for a N-by-M dataset 'features' with N instances and M features, predictions = sign

Feature Selection and Reduction for Text Classification

匆匆过客 提交于 2019-12-29 10:06:31
问题 I am currently working on a project, a simple sentiment analyzer such that there will be 2 and 3 classes in separate cases . I am using a corpus that is pretty rich in the means of unique words (around 200.000). I used bag-of-words method for feature selection and to reduce the number of unique features , an elimination is done due to a threshold value of frequency of occurrence . The final set of features includes around 20.000 features, which is actually a 90% decrease , but not enough for

Training of SVM classifier using SIFT features

徘徊边缘 提交于 2019-12-29 07:17:30
问题 please i like to classify a set of image in 4 class with SIFT DESCRIPTOR and SVM. Now, using SIFT extractor I get keypoints of different sizes exemple img1 have 100 keypoints img2 have 55 keypoints.... how build histograms that give fixed size vectors with matlab 回答1: In this case, perhaps dense sift is a good choice. There are two main stages: Stage 1 : Creating a codebook. Divide the input image into a set of sub-images. Apply sift on each sub-image. Each key point will have 128 dimensional

predict.svm does not predict new data

对着背影说爱祢 提交于 2019-12-29 06:59:16
问题 unfortunately I have problems using predict() in the following simple example: library(e1071) x <- c(1:10) y <- c(0,0,0,0,1,0,1,1,1,1) test <- c(11:15) mod <- svm(y ~ x, kernel = "linear", gamma = 1, cost = 2, type="C-classification") predict(mod, newdata = test) The result is as follows: > predict(mod, newdata = test) 1 2 3 4 <NA> <NA> <NA> <NA> <NA> <NA> 0 0 0 0 0 1 1 1 1 1 Can anybody explain why predict() only gives the fitted values of the training sample (x,y) and does not care about

predict.svm does not predict new data

与世无争的帅哥 提交于 2019-12-29 06:58:07
问题 unfortunately I have problems using predict() in the following simple example: library(e1071) x <- c(1:10) y <- c(0,0,0,0,1,0,1,1,1,1) test <- c(11:15) mod <- svm(y ~ x, kernel = "linear", gamma = 1, cost = 2, type="C-classification") predict(mod, newdata = test) The result is as follows: > predict(mod, newdata = test) 1 2 3 4 <NA> <NA> <NA> <NA> <NA> <NA> 0 0 0 0 0 1 1 1 1 1 Can anybody explain why predict() only gives the fitted values of the training sample (x,y) and does not care about

SVM文本分类

南笙酒味 提交于 2019-12-28 21:09:32
一.理论方法介绍 SVM(Support Vector Machine)指的是支持向量机,是常见的一种判别方法。在机器学习领域,是一个有监督的学习模型,可以用来进行分类研究。 SVM二分类 SVM二分类的基本思想是在特征空间中寻找间隔最大的分离超平面使数据得到高效的二分类,有三种情况: 当训练样本线性可分时,通过硬间隔最大化,学习一个线性分类器,即线性可分支持向量机; 当训练数据近似线性可分时,引入松弛变量,通过软间隔最大化,学习一个线性分类器,即线性支持向量机; 当训练数据线性不可分时,通过引入核函数技巧及软间隔最大化,学习非线性支持向量机。 svm多分类 svm本身是一个追求类别超平面间支持向量距离最大化的二分类器,本实验的目标是对于三种不同类型文本构造分类器,属于多分类问题。主要是通过组合多个二分类器来实现多分类器的构造,多分类通常有一对多,一对一,多对多等。实验中采取的是one-versus-rest一对多方法,简称OVR SVMs。训练步骤如下: 首先A类对应的向量作为正样本,B,C对应的样本作为负样本 B对应的向量作为正样本,A,C对应的向量作为负样本 C对应的向量作为正样本,A,B对应的向量作为负样本 这3个训练集分别进行训练,得到四个训练结果文件 测试时,把对应的测试向量分别利用这三个结果进行文件测试 得到三个分类结果:y1(x),y2(x),y3(x)

支持向量机SVM推导

天涯浪子 提交于 2019-12-28 03:25:30
样本(\(x_{i}\),\(y_{i}\))个数为\(m\): \[\{x_{1},x_{2},x_{3}...x_{m}\}\] \[\{y_{1},y_{2},y_{3}...y_{m}\}\] 其中\(x_{i}\)为\(n\)维向量: \[x_{i}=\{x_{i1},x_{i2},x_{i3}...x_{in}\}\] 其中\(y_i\)为类别标签: \[y_{i}\in\{-1,1\}\] 其中\(w\)为\(n\)维向量: \[w=\{w_{1},w_{2},w_{3}...w_{n}\}\] 函数间隔\(r_{fi}\): \[ r_{fi}=y_i(wx_i+b) \] 几何间隔\(r_{di}\): \[ r_{di}=\frac{r_{fi}}{\left \| w \right \|} =\frac{y_i(wx_i+b)}{\left \| w \right \|} \] 最小函数间隔\(r_{fmin}\): \[ r_{fmin}=\underset{i}{min}\{y_i(wx_i+b)\} \] 最小几何间隔\(r_{dmin}\): \[ r_{dmin}=\frac{r_{fmin}}{\left \| w \right \|} =\frac{1}{\left \| w \right \|}*\underset{i}{min}\{y_i

OpenCV unable to set up SVM Parameters

送分小仙女□ 提交于 2019-12-28 03:03:53
问题 I have just started my learning on SVM using C++ OpenCV and was referring to the SVM documentation here. I wanted to try out the sample source code from the link to get familiar with it first but I couldn't run the sample source code. It returns the error : Error 1 error C2065: 'CvSVMParams' : undeclared identifier I'm using Visual Studio 2012 with OpenCV 3.0.0. The setup process should be correct as all other codes are working well except this. 回答1: A lot of things changed from OpenCV 2.4 to

SVM支持向量机

大城市里の小女人 提交于 2019-12-28 00:27:29
一个比较好的学习资源: http://www.aibbt.com/a/21005.html 看完了优达学城的机器学习基础的课程,发现没有讲解具体怎么实现学习曲线和复杂度曲线的,这里还是需要自己去网上查一下。 http://www.aibbt.com/a/21443.html 原来C参数是这样来的!松弛变量。 虽然我们不想深挖SVM背后的数学概念,但还是有必要简短介绍一下松弛变量(slack variable) ,它是由Vladimir Vapnik在1995年引入的,借此提出了软间隔分类(soft-margin)。引入松弛变量的动机是原来的线性限制条件在面对非线性可分数据时需要松弛,这样才能保证算法收敛。 松弛变量值为正,添加到线性限制条件即可: 新的目标函数变成了: 使用变量C,我们可以控制错分类的惩罚量。和逻辑斯蒂回归不同,这里C越大,对于错分类的惩罚越大。可以通过C控制间隔的宽度,在bias-variance之间找到某种平衡: 哇,这个资源太好了!很具体哦 注意看右上角子图到右下角子图的转变,高维空间中的线性决策界实际上是低维空间的非线性决策界,这个非线性决策界是线性分类器找不到的,而核方法找到了: 使用核技巧在高维空间找到可分超平面 使用SVM解决非线性问题,我们通过映射函数 将训练集映射到高维特征空间,然后训练一个线性SVM模型在新特征空间将数据分类。然后

Multi-class classification in libsvm [closed]

試著忘記壹切 提交于 2019-12-27 17:06:09
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I'm working with libsvm and I must implement the classification for multiclasses with one versus all . How can I do it? Does libsvm version 2011 use this? I think that my question is not very clear. if libsvm don