支持向量机matlab实例及理论_20131201

合集下载

支持向量机(SVM)、支持向量机回归(SVR):原理简述及其MATLAB实例

支持向量机(SVM)、支持向量机回归(SVR):原理简述及其MATLAB实例

支持向量机(SVM)、支持向量机回归(SVR):原理简述及其MATLAB实例一、基础知识1、关于拉格朗日乘子法和KKT条件1)关于拉格朗日乘子法2)关于KKT条件2、范数1)向量的范数2)矩阵的范数3)L0、L1与L2范数、核范数二、SVM概述1、简介2、SVM算法原理1)线性支持向量机2)非线性支持向量机二、SVR:SVM的改进、解决回归拟合问题三、多分类的SVM1. one-against-all2. one-against-one四、QP(二次规划)求解五、SVM的MATLAB实现:Libsvm1、Libsvm工具箱使用说明2、重要函数:3、示例支持向量机(SVM):原理及其MATLAB实例一、基础知识1、关于拉格朗日乘子法和KKT条件1)关于拉格朗日乘子法首先来了解拉格朗日乘子法,为什么需要拉格朗日乘子法呢?记住,有需要拉格朗日乘子法的地方,必然是一个组合优化问题。

那么带约束的优化问题很好说,就比如说下面这个:这是一个带等式约束的优化问题,有目标值,有约束条件。

那么你可以想想,假设没有约束条件这个问题是怎么求解的呢?是不是直接 f 对各个 x 求导等于 0,解 x 就可以了,可以看到没有约束的话,求导为0,那么各个x均为0吧,这样f=0了,最小。

但是x都为0不满足约束条件呀,那么问题就来了。

有了约束不能直接求导,那么如果把约束去掉不就可以了吗?怎么去掉呢?这才需要拉格朗日方法。

既然是等式约束,那么我们把这个约束乘一个系数加到目标函数中去,这样就相当于既考虑了原目标函数,也考虑了约束条件。

现在这个优化目标函数就没有约束条件了吧,既然如此,求法就简单了,分别对x求导等于0,如下:把它在带到约束条件中去,可以看到,2个变量两个等式,可以求解,最终可以得到,这样再带回去求x就可以了。

那么一个带等式约束的优化问题就通过拉格朗日乘子法完美的解决了。

更高一层的,带有不等式的约束问题怎么办?那么就需要用更一般化的拉格朗日乘子法,即KKT条件,来解决这种问题了。

支持向量机介绍课件

支持向量机介绍课件
04 多分类支持向量机:适用于多分类问题,将多个 二分类支持向量机组合成一个多分类支持向量机
支持向量机的应用场景
01
分类问题:支持向量机可以用于 解决二分类或多分类问题,如文 本分类、图像分类等。
03
异常检测:支持向量机可以用于 异常检测,如信用卡欺诈检测、 网络入侵检测等。
02
回归问题:支持向量机可以用于 解决回归问题,如房价预测、股 票价格预测等。
4 支持向量机的优缺点
优点
01
高度泛化:支持向量机具有 很强的泛化能力,能够有效 地处理非线性问题。
02
鲁棒性:支持向量机对异常 值和噪声具有较强的鲁棒性, 能够有效地避免过拟合。
03
计算效率:支持向量机的训 练和预测过程相对较快,能 够有效地处理大规模数据。
04
易于解释:支持向量机的决 策边界直观易懂,便于理解 和解释。
缺点
01
计算复杂度高: 支持向量机的训 练和预测都需要 较高的计算复杂 度
02
容易过拟合:支 持向量机在处理 高维数据时容易 发生过拟合现象
03
模型选择困难:支 持向量机的参数选 择和模型选择较为 困难,需要一定的 经验和技巧
04
不适用于线性不可 分问题:支持向量 机只适用于线性可 分问题,对于非线 性问题需要进行复 杂的特征转换或采 用其他算法
它通过引入松弛变量,允许某些
02
数据点在分类超平面的两侧。 软间隔分类器的目标是最大化间 03 隔,同时最小化松弛变量的数量。 软间隔分类器可以通过求解二次
04
规划问题得到。
3 支持向量机的应用
线性分类
01
支持向量机 可以用于线 性分类问题
02
线性分类器可 以找到最优的

支持向量机(SVM)算法的matlab的实现

支持向量机(SVM)算法的matlab的实现

⽀持向量机(SVM)算法的matlab的实现⽀持向量机(SVM)的matlab的实现⽀持向量机是⼀种分类算法之中的⼀个,matlab中也有对应的函数来对其进⾏求解;以下贴⼀个⼩例⼦。

这个例⼦来源于我们实际的项⽬。

clc;clear;N=10;%以下的数据是我们实际项⽬中的训练例⼦(例⼦中有8个属性)correctData=[0,0.2,0.8,0,0,0,2,2];errorData_ReversePharse=[1,0.8,0.2,1,0,0,2,2];errorData_CountLoss=[0.2,0.4,0.6,0.2,0,0,1,1];errorData_X=[0.5,0.5,0.5,1,1,0,0,0];errorData_Lower=[0.2,0,1,0.2,0,0,0,0];errorData_Local_X=[0.2,0.2,0.8,0.4,0.4,0,0,0];errorData_Z=[0.53,0.55,0.45,1,0,1,0,0];errorData_High=[0.8,1,0,0.8,0,0,0,0];errorData_CountBefore=[0.4,0.2,0.8,0.4,0,0,2,2];errorData_Local_X1=[0.3,0.3,0.7,0.4,0.2,0,1,0];sampleData=[correctData;errorData_ReversePharse;errorData_CountLoss;errorData_X;errorData_Lower;errorData_Local_X;errorData_Z;errorData_High;errorData_CountBefore;errorData_Local_X1];%训练例⼦type1=1;%正确的波形的类别,即我们的第⼀组波形是正确的波形,类别号⽤ 1 表⽰type2=-ones(1,N-2);%不对的波形的类别,即第2~10组波形都是有故障的波形。

matlab-支持向量机包及用法

matlab-支持向量机包及用法

matlab-支持向量机包及用法chapter one: matlab高级版本中自带的svm函数我现在使用的matlab版本为matlab 7.6.0(R2008a)这个版本中已经自带svm算法,分别为生物信息工具箱(bioinformatics toolbox)中svmclassify函数和svmtrain函数,为上下级关系。

SVMStruct=svmtrain(Training,Group)%svmtrain的输入为样本点training和样本的分类情况group,输出为一个分类器svmstruct.核函数,核参数,和计算方法等都是可选的,如SVMStruct = svmtrain(…, ‘Kernel_Function’, Kernel_FunctionValue, …)但是切记切记一定要成对出现。

然后,将分类器和testing sample带入svmclassify中,可以得到分类结果和准确度。

举个例子哈svmStruct = svmtrain(data(train,:),groups(train),’Kernel_Function’,'rbf’,'Ke rnel_FunctionValue’,’5′,’showplot’,true);%用了核宽为5的径向基核,且要求作图%这里我觉得原作者的写法有误,应该是svmStruct = svmtrain(data(train,:),groups(train),...'Kernel_Function','rbf','RBF_Sigma',5,'showplot',true);classes = svmclassify(svmStruct,data(test,:),’showplot’,true);%要求输出检测样本点的分类结果,且画图表示。

tip 1: 有归一化scale功能,可以通过调参数实现tip 2: 计算方法可选qp,smo,lstip 3: 有个关于soft margin的盒子条件,我不太明白是干嘛的,谁懂得话,就给我讲讲哈tip 4: 画出来的图很难看to sum up: 挺好的chapter two: 我最早使用的工具箱SVM and Kernel Methods Matlab Toolbox2005年法国人写的,最近的更新为20/02/2008下载的地址为http://asi.insa-rouen.fr/enseignants/~arakotom/toolbox/index.html这是我最早开始用的一个工具箱,我很喜欢,到现在还是,对于svm的初学者是个很好的toolbox.有详细的说明和很多的demo和例子,包含现今几乎所有的有关svm的成熟算法和数据预处理方法(pca及小波等)。

Matlab中的支持向量机与核方法理论与应用

Matlab中的支持向量机与核方法理论与应用

Matlab中的支持向量机与核方法理论与应用引言支持向量机(Support Vector Machine, SVM)是一种强大的机器学习算法,常被用于分类和回归问题的解决。

SVM的核方法是其重要的扩展,通过将输入数据映射到高维特征空间,能够更好地捕获数据的非线性关系。

本文将介绍Matlab中的支持向量机与核方法的理论和应用,探讨其在实际问题中的应用价值。

一、支持向量机的原理支持向量机是一种二分类的监督学习算法。

其基本思想是找到一个超平面,使得两个不同类别的数据样本能够被最大化地分隔开。

这个超平面由支持向量组成,支持向量是离超平面最近的训练样本点。

Matlab中的SVM算法可以通过libsvm或svmtrain函数来实现。

通过选择不同的核函数,如线性核、多项式核、高斯核等,可以实现不同的分类问题的解决。

SVM算法的训练过程是寻找一个最优的超平面,使其能够正确分类训练数据,并保证分类边界的间隔最大化。

二、核方法的原理核方法是SVM的重要扩展,通过将输入数据映射到高维特征空间,能够更好地捕获数据的非线性关系。

核函数的选择非常重要,常用的核函数有线性核、多项式核、高斯核等。

核方法的核心思想是在计算过程中使用核函数代替内积计算,避免了显示地进行特征映射,从而大幅度提高了计算效率。

核方法能够将原始的低维数据映射到高维特征空间,使得原本线性不可分的数据在高维空间中变得线性可分。

Matlab中提供了丰富的核函数,比如线性核函数、多项式核函数、高斯核函数等,用户可以根据实际问题选择适合的核函数,以达到更好的分类效果。

三、支持向量机与核方法的应用支持向量机与核方法在实际问题中有广泛的应用。

以下列举几个典型的应用场景:1. 图像分类支持向量机与核方法在图像分类问题中有很好的应用前景。

通过将图像样本映射到高维特征空间,可以提取出更多的图像特征信息,并将其用于分类任务中。

例如,可以通过SVM和核方法识别人脸、车辆等目标。

支持向量机PPT课件

支持向量机PPT课件
2023
支持向量机ppt课件
https://
REPORTING
2023
目录
• 支持向量机概述 • 支持向量机的基本原理 • 支持向量机的实现步骤 • 支持向量机的应用案例 • 支持向量机的未来发展与挑战 • 总结与展望
2023
PART 01
支持向量机概述
REPORTING
详细描述
传统的支持向量机通常是针对单个任务进行训练和预测,但在实际应用中,经常需要处理多个相关任务。多任务 学习和迁移学习技术可以通过共享特征或知识,使得支持向量机能够更好地适应多个任务,提高模型的泛化性能。
深度学习与神经网络的结合
总结词
将支持向量机与深度学习或神经网络相结合,可以发挥各自的优势,提高模型的性能和鲁棒性。
模型训练
使用训练集对支持向量机模型进行训练。
参数调整
根据验证集的性能指标,调整模型参数,如惩罚因子C和核函数类 型等。
模型优化
采用交叉验证、网格搜索等技术对模型进行优化,提高模型性能。
模型评估与调整
性能评估
使用测试集对模型进行 评估,计算准确率、召 回率、F1值等指标。
模型对比
将支持向量机与其他分 类器进行对比,评估其 性能优劣。
模型调整
根据评估结果,对模型 进行调整,如更换核函 数、调整参数等,以提 高性能。
2023
PART 04
支持向量机的应用案例
REPORTING
文本分类
总结词
利用支持向量机对文本数据进行分类 ,实现文本信息的有效管理。
详细描述
支持向量机在文本分类中发挥了重要 作用,通过对文本内容的特征提取和 分类,能够实现新闻分类、垃圾邮件 过滤、情感分析等应用。

Matlab中的支持向量机应用

Matlab中的支持向量机应用

Matlab中的支持向量机应用在机器学习领域中,支持向量机(Support Vector Machine,SVM)是一种非常重要的分类和回归算法。

SVM具有很好的泛化性能和较强的鲁棒性,因此在实际应用中得到了广泛的应用。

在本文中,将重点介绍SVM在Matlab中的应用。

一. SVM算法原理支持向量机是一种基于统计学习理论的二分类模型。

其主要思想是寻找一个超平面,使得离该超平面最近的样本点到该超平面的距离最大化。

这些离超平面最近的样本点被称为支持向量。

SVM的目标是找到一个最优的超平面,使得正负样本点之间的间隔最大化。

如果数据是线性可分的,那么SVM就能找到一个分离超平面。

如果数据是线性不可分的,SVM通过引入松弛变量和核函数来处理。

二. Matlab中的SVM工具箱Matlab是一种非常方便的科学计算软件,它提供了丰富的工具箱和函数用于机器学习和数据分析。

在Matlab中,可以使用统计和机器学习工具箱中的函数来实现支持向量机算法。

使用SVM工具箱可以方便地进行数据预处理、模型选择、模型训练和测试等操作。

三. 数据处理与特征选择在使用SVM算法之前,首先需要对数据进行处理和特征选择。

常见的数据处理包括数据清洗、数据标准化和数据归一化等操作。

特征选择是指从原始数据中选择一些最重要的特征用于训练模型。

常用的特征选择方法有相关系数、卡方检验、互信息等。

Matlab提供了丰富的函数和工具箱可以帮助进行数据处理和特征选择。

四. 模型选择与参数调优在使用SVM算法时,需要选择一个合适的模型和调优相关的参数。

模型选择包括选择合适的核函数、惩罚参数以及其他超参数。

常见的核函数包括线性核函数、多项式核函数和径向基核函数等。

而参数调优可以使用交叉验证等方法选择出最优的参数。

Matlab提供了交叉验证工具和函数来帮助进行模型选择和参数调优。

五. 模型训练与测试在确定了模型和参数后,可以使用支持向量机工具箱中的函数进行模型训练和测试。

支持向量机matlab例题

支持向量机matlab例题

支持向量机matlab例题当涉及到支持向量机(Support Vector Machine,简称SVM)的例题时,我们可以通过MATLAB来实现和解决。

SVM是一种常用的机器学习算法,用于分类和回归任务。

下面我将给出一个SVM的MATLAB例题,以帮助你更好地理解和应用该算法。

假设我们有一个二维数据集,其中包含两个类别的数据点。

我们的目标是使用SVM对这些数据进行分类。

首先,我们需要创建一个示例数据集。

在MATLAB中,我们可以使用`randn`函数生成随机数据。

假设我们有两个类别,每个类别有100个样本点。

代码如下:matlab.% 生成数据。

rng(1); % 设置随机种子,以确保结果可重现。

n = 100; % 每个类别的样本数量。

X1 = randn(n, 2) + repmat([1, 1], n, 1); % 类别1的数据点。

X2 = randn(n, 2) + repmat([-1, -1], n, 1); % 类别2的数据点。

X = [X1; X2]; % 合并数据。

y = [ones(n, 1); -ones(n, 1)]; % 类别标签。

接下来,我们可以使用`fitcsvm`函数来训练SVM模型,并进行分类。

代码如下:matlab.% 训练SVM模型。

svmModel = fitcsvm(X, y);% 预测分类结果。

y_pred = predict(svmModel, X);现在,我们已经得到了预测的分类结果。

我们可以使用`plot`函数将数据点和决策边界可视化。

代码如下:matlab.% 可视化结果。

figure;gscatter(X(:, 1), X(:, 2), y, 'rb', 'o');hold on;% 绘制决策边界。

h = svmModel.Beta(1);k = svmModel.Beta(2);x1 = linspace(min(X(:, 1)), max(X(:, 1)), 100);x2 = (-svmModel.Bias h x1) / k;plot(x1, x2, 'k--', 'LineWidth', 2);% 设置图形属性。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

支持向量机matlab分类实例及理论线性支持向量机可对线性可分的样本群进行分类,此时不需要借助于核函数就可较为理想地解决问题。

非线性支持向量机将低维的非线性分类问题转化为高维的线性分类问题,然后采用线性支持向量机的求解方法求解。

此时需要借助于核函数,避免线性分类问题转化为非线性分类问题时出现的维数爆炸难题,从而避免由于维数太多而无法进行求解。

第O层:Matlab的SVM函数求解分类问题实例0.1 Linear classification%Two Dimension Linear-SVM Problem, Two Class and Separable Situation %Method from Christopher J. C. Burges:%"A Tutorial on Support Vector Machines for Pattern Recognition", page 9%Optimizing ||W|| directly:% Objective: min "f(A)=||W||" , p8/line26% Subject to: yi*(xi*W+b)-1>=0, function (12);clear all;close allclc;sp=[3,7; 6,6; 4,6;5,6.5] % positive sample pointsnsp=size(sp);sn=[1,2; 3,5;7,3;3,4;6,2.7] % negative sample pointsnsn=size(sn)sd=[sp;sn]lsd=[true true true true false false false false false]Y = nominal(lsd)figure(1);subplot(1,2,1)plot(sp(1:nsp,1),sp(1:nsp,2),'m+');hold onplot(sn(1:nsn,1),sn(1:nsn,2),'c*');subplot(1,2,2)svmStruct = svmtrain(sd,Y,'showplot',true);0.2 NonLinear classificationclear all;close allclc;sp=[3,7; 6,6; 4,6; 5,6.5] % positive sample pointsnsp=size(sp);sn=[1,2; 3,5; 7,3; 3,4; 6,2.7; 4,3;2,7] % negative sample points nsn=size(sn)sd=[sp;sn]lsd=[true true true true false false false false false false false] Y = nominal(lsd)figure(1);subplot(1,2,1)plot(sp(1:nsp,1),sp(1:nsp,2),'m+');hold onplot(sn(1:nsn,1),sn(1:nsn,2),'c*');subplot(1,2,2)% svmStruct = svmtrain(sd,Y,'Kernel_Function','linear','showplot',true);svmStruct = svmtrain(sd,Y,'Kernel_Function','quadratic','showplot',true);% use the trained svm (svmStruct) to classify the dataRD=svmclassify(svmStruct,sd,'showplot',true)% RD is the classification result vector0.3 Gaussian Kernal Classificationclear all;close allclc;sp=[5,4.5;3,7; 6,6; 4,6; 5,6.5] % positive sample pointsnsp=size(sp);sn=[1,2; 3,5; 7,3; 3,4; 6,2.7; 4,3;2,7] % negative sample pointsnsn=size(sn)sd=[sp;sn]lsd=[true true true true true false false false false false false false] Y = nominal(lsd)figure(1);subplot(1,2,1)plot(sp(1:nsp,1),sp(1:nsp,2),'m+');hold onplot(sn(1:nsn,1),sn(1:nsn,2),'c*');subplot(1,2,2)svmStruct =svmtrain(sd,Y,'Kernel_Function','rbf','rbf_sigma',0.6,'method','SMO', 'showplot',true);% svmStruct = svmtrain(sd,Y,'Kernel_Function','quadratic','showplot',true);% use the trained svm (svmStruct) to classify the dataRD=svmclassify(svmStruct,sd,'showplot',true)% RD is the classification result vectorsvmtrain(sd,Y,'Kernel_Function','rbf','rbf_sigma',0.2,'method','SM O','showplot',true);0.4 Svmtrain Functionsvmtrain Train a support vector machine classifierSVMSTRUCT = svmtrain(TRAINING, Y) trains a support vector machine (SVM) classifier on data taken from two groups. TRAINING is a numeric matrix of predictor data. Rows of TRAINING correspond to observations; columns correspond to features. Y is a column vector that contains the known class labels for TRAINING. Y is a grouping variable, i.e., it can be acategorical, numeric, or logical vector; a cell vector of strings; or a character matrix with each row representing a class label (see help forgroupingvariable). Each element of Y specifies the group thecorresponding row of TRAINING belongs to. TRAINING and Y must have thesame number of rows. SVMSTRUCT contains information about the trained classifier, including the support vectors, that is used by SVMCLASSIFY for classification. svmtrain treats NaNs, empty strings or 'undefined' values as missing values and ignores the corresponding rows inTRAINING and Y.SVMSTRUCT = svmtrain(TRAINING, Y, 'PARAM1',val1, 'PARAM2',val2, ...) specifies one or more of the following name/value pairs:Name Value'kernel_function' A string or a function handle specifying the kernel function used to represent the dotproduct in a new space. The value can be one of the following:'linear' - Linear kernel or dot product(default). In this case, svmtrainfinds the optimal separating plane in the original space.'quadratic' - Quadratic kernel'polynomial' - Polynomial kernel with defaultorder 3. To specify another order, use the 'polyorder' argument.'rbf' - Gaussian Radial Basis Functionwith default scaling factor 1. Tospecify another scaling factor,use the 'rbf_sigma' argument.'mlp' - Multilayer Perceptron kernel (MLP) with default weight 1 and defaultbias -1. To specify another weight or bias, use the 'mlp_params'argument.function - A kernel function specified using @(for example @KFUN), or ananonymous function. A kernelfunction must be of the formfunction K = KFUN(U, V)The returned value, K, is a matrix of size M-by-N, where M and N arethe number of rows in U and Vrespectively.'rbf_sigma' A positive number specifying the scaling factor in the Gaussian radial basis function kernel.Default is 1.'polyorder' A positive integer specifying the order of the polynomial kernel. Default is 3.'mlp_params' A vector [P1 P2] specifying the parameters of MLP kernel. The MLP kernel takes the form:K = tanh(P1*U*V' + P2),where P1 > 0 and P2 < 0. Default is [1,-1].'method' A string specifying the method used to find the separating hyperplane. Choices are:'SMO' - Sequential Minimal Optimization (SMO)method (default). It implements the L1soft-margin SVM classifier.'QP' - Quadratic programming (requires anOptimization Toolbox license). Itimplements the L2 soft-margin SVMclassifier. Method 'QP' doesn't scalewell for TRAINING with large number ofobservations.'LS' - Least-squares method. It implements the L2 soft-margin SVM classifier.'options' Options structure created using either STATSET or OPTIMSET.* When you set 'method' to 'SMO' (default),create the options structure using STATSET.Applicable options:'Display' Level of display output. Choicesare 'off' (the default), 'iter', and'final'. Value 'iter' reports every500 iterations.'MaxIter' A positive integer specifying themaximum number of iterations allowed. Default is 15000 for method 'SMO'.* When you set method to 'QP', create theoptions structure using OPTIMSET. For details of applicable options choices, see QUADPROGoptions. SVM uses a convex quadratic program,so you can choose the 'interior-point-convex' algorithm in QUADPROG.'tolkkt' A positive scalar that specifies the tolerance with which the Karush-Kuhn-Tucker (KKT) conditions are checked for method 'SMO'. Default is1.0000e-003.'kktviolationlevel' A scalar specifying the fraction of observations that are allowed to violate the KKT conditions for method 'SMO'. Setting this value to be positive helps the algorithm to converge faster if it is fluctuating near a good solution. Default is 0.'kernelcachelimit' A positive scalar S specifying the size of the kernel matrix cache for method 'SMO'. Thealgorithm keeps a matrix with up to S * Sdouble-precision numbers in memory. Default is5000. When the number of points in TRAININGexceeds S, the SMO method slows down. It'srecommended to set S as large as your systempermits.'boxconstraint' The box constraint C for the soft margin. C can bea positive numeric scalar or a vector of positive numbers with the number of elements equal to the number of rows in TRAINING.Default is 1.* If C is a scalar, it is automatically rescaled by N/(2*N1) for the observations of group one, and by N/(2*N2) for the observations of group two, where N1 is the number of observations in group one, N2 is the number of observations in group two. The rescaling is done to take into account unbalanced groups, i.e., when N1 and N2 are different.* If C is a vector, then each element of Cspecifies the box constraint for thecorresponding observation.'autoscale' A logical value specifying whether or not toshift and scale the data points before training. When the value is true, the columns of TRAININGare shifted and scaled to have zero mean unitvariance. Default is true.'showplot' A logical value specifying whether or not to show a plot. When the value is true, svmtrain creates a plot of the grouped data and the separating line for the classifier, when using data with 2features (columns). Default is false.SVMSTRUCT is a structure having the following properties:SupportVectors Matrix of data points with each row corresponding to a support vector.Note: when 'autoscale' is false, this fieldcontains original support vectors in TRAINING.When 'autoscale' is true, this field containsshifted and scaled vectors from TRAINING.Alpha Vector of Lagrange multipliers for the support vectors. The sign is positive for support vectors belonging to the first group and negative forsupport vectors belonging to the second group.Bias Intercept of the hyperplane that separatesthe two groups.Note: when 'autoscale' is false, this fieldcorresponds to the original data points inTRAINING. When 'autoscale' is true, this fieldcorresponds to shifted and scaled data points.KernelFunction The function handle of kernel function used.KernelFunctionArgs Cell array containing the additional arguments for the kernel function.GroupNames A column vector that contains the knownclass labels for TRAINING. Y is a groupingvariable (see help for groupingvariable).SupportVectorIndices A column vector indicating the indices of support vectors.ScaleData This field contains information about auto-scale. When 'autoscale' is false, it is empty. When'autoscale' is set to true, it is a structurecontaining two fields:shift - A row vector containing the negative of the mean across all observations in TRAINING.scaleFactor - A row vector whose value is1./STD(TRAINING).FigureHandles A vector of figure handles created by svmtrain when 'showplot' argument is TRUE.Example:% Load the data and select features for classificationload fisheririsX = [meas(:,1), meas(:,2)];% Extract the Setosa classY = nominal(ismember(species,'setosa'));% Randomly partitions observations into a training set and a test % set using stratified holdoutP = cvpartition(Y,'Holdout',0.20);% Use a linear support vector machine classifiersvmStruct =svmtrain(X(P.training,:),Y(P.training),'showplot',true);C = svmclassify(svmStruct,X(P.test,:),'showplot',true);errRate = sum(Y(P.test)~= C)/P.TestSize %mis-classification rate conMat = confusionmat(Y(P.test),C) % the con第一层、了解SVM1.0、什么是支持向量机SVM要明白什么是SVM,便得从分类说起。

相关文档
最新文档