模式识别(3)-SVM分类算法

来源:互联网 发布:js 获取table tr td 编辑:程序博客网 时间:2024/06/08 12:38

3.1.SVM算法原理和分析
SVM(Support Vector Machines),中文名字叫做支持矢量机。SVM也是寻找一个超平面,使得训练集中的点距离分类面尽可能的远,就是让这个分类面两侧放入空白区域最大。
支持矢量就是距离分类平面最近的一些样本点,对决策面的选取有决策作用。

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

SVM训练代码:

clear allclose allN1=440;for i=1:N1x1(1,i)=-1.7+1.1*randn(1);% 440 Samples normal distributionx1(2,i)= 1.6+0.9*randn(1);%x1(3,i)= 1;end;N2=400;for i=1:N2x2(1,i)= 1.3+1.0*randn(1);% 400 Samples normal distriburionx2(2,i)=-1.5+0.8*randn(1);%x2(3,i)= 1;end;plot(x1(1,:),x1(2,:),'ro',x2(1,:),x2(2,:),'g*');hold on;y1 = ones(440,1);y2 = -ones(400,1);12train =[x1';x2'];%将两组数据合为一组group = [y1;y2];test =[x1';x2'];svmModel =svmtrain(train,group,'kernel_function','linear','showplot',true);%SVM 训练数据模型classification=svmclassify(svmModel,test,'Showplot',true); %用测试数据测试,画出决策面。
原创粉丝点击