没有合适的资源?快使用搜索试试~ 我知道了~
支持向量机matlab实例及理论.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 15 浏览量
2022-07-05
11:13:23
上传
评论 1
收藏 2.06MB DOCX 举报
温馨提示
试读
61页
支持向量机matlab实例及理论
资源推荐
资源详情
资源评论
支持向量机 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 all
clc;
sp=[3,7; 6,6; 4,6;5,6.5] % positive sample points
nsp=size(sp);
sn=[1,2; 3,5;7,3;3,4;6,2.7] % negative sample points
nsn=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 on
plot(sn(1:nsn,1),sn(1:nsn,2),'c*');
subplot(1,2,2)
svmStruct = svmtrain(sd,Y,'showplot',true);
0.2 NonLinear classification
clear all;
close all
clc;
sp=[3,7; 6,6; 4,6; 5,6.5] % positive sample points
nsp=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 on
plot(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 data
RD=svmclassify(svmStruct,sd,'showplot',true)
% RD is the classification result vector
0.3 Gaussian Kernal Classification
clear all;
close all
clc;
sp=[5,4.5;3,7; 6,6; 4,6; 5,6.5] % positive sample points
nsp=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 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 on
plot(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 data
RD=svmclassify(svmStruct,sd,'showplot',true)
% RD is the classification result vector
svmtrain(sd,Y,'Kernel_Function','rbf','rbf_sigma',0.2,'method','SM
O','showplot',true);
0.4 Svmtrain Function
svmtrain Train a support vector machine classifier
SVMSTRUCT = 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 a
categorical, numeric, or logical vector; a cell vector of
strings; or a character matrix with each row representing a class
label (see help for
groupingvariable). Each element of Y specifies the group the
corresponding row of TRAINING belongs to. TRAINING and Y must
have the
same 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 in
TRAINING 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 dot
product in a new space. The value can be
one of
the following:
'linear' - Linear kernel or dot product
(default). In this case,
svmtrain
finds the optimal separating
plane
in the original space.
'quadratic' - Quadratic kernel
'polynomial' - Polynomial kernel with
default
order 3. To specify another
order,
use the 'polyorder'
argument.
'rbf' - Gaussian Radial Basis
Function
with default scaling factor
1. To
specify another scaling
factor,
剩余60页未读,继续阅读
资源评论
oligaga
- 粉丝: 52
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IMG_0694.GIF
- 基于图像的三维模型重建C++源代码+文档说明(高分课程设计)
- 基于聚焦法的工件立体测量方案,根据数据进行三维重建 使用HALCON处理图像,MATLAB拟合数据+源代码+数据集+效果图
- 锄战三国村 修改:货币使用不减 v1.10(2) 原创 (中文).apk
- 基于python实现的单目双目视觉三维重建+源代码+图像图片(高分课程设计)
- 基于C+++OPENCV的全景图像拼接源码(课程设计)
- 基于Python+OpenCV对多张图片进行全景图像拼接,消除鬼影,消除裂缝+源代码+文档说明+界面截图(高分课程设计)
- 基于C++实现的全景图像拼接源码(课程设计)
- 基于SIFT特征点提取和RASIC算法实现全景图像拼接python源码+文档说明+界面截图+详细注释(95分以上课程大作业)
- 基于matlab实现眼部判别的疲劳检测系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功