预览加载中,请您耐心等待几秒...
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

SVM工具箱快速入手简易教程(byfaruto)一.matlab自带的函数(matlab帮助文件里的例子)[只有较新版本的matlab中有这两个SVM的函数]=====svmtrainsvmclassify=====简要语法规则====svmtrainTrainsupportvectormachineclassifierSyntaxSVMStruct=svmtrain(Training,Group)SVMStruct=svmtrain(...,'Kernel_Function',Kernel_FunctionValue,...)SVMStruct=svmtrain(...,'RBF_Sigma',RBFSigmaValue,...)SVMStruct=svmtrain(...,'Polyorder',PolyorderValue,...)SVMStruct=svmtrain(...,'Mlp_Params',Mlp_ParamsValue,...)SVMStruct=svmtrain(...,'Method',MethodValue,...)SVMStruct=svmtrain(...,'QuadProg_Opts',QuadProg_OptsValue,...)SVMStruct=svmtrain(...,'SMO_Opts',SMO_OptsValue,...)SVMStruct=svmtrain(...,'BoxConstraint',BoxConstraintValue,...)SVMStruct=svmtrain(...,'Autoscale',AutoscaleValue,...)SVMStruct=svmtrain(...,'Showplot',ShowplotValue,...)---------------------svmclassifyClassifydatausingsupportvectormachineSyntaxGroup=svmclassify(SVMStruct,Sample)Group=svmclassify(SVMStruct,Sample,'Showplot',ShowplotValue)============================实例研究====================loadfisheriris%载入matlab自带的数据[有关数据的信息可以自己到UCI查找,这是UCI的经典数据之一],得到的数据如下图:tu1HYPERLINK"http://www.ilovematlab.cn/attachment.php?aid=24862&k=5efc27ffe8e1ec9b74c29268689e3889&t=1263976450&nothumb=yes"\t"_blank"1.jpg(7.94KB)2009-5-1219:50其中meas是150*4的矩阵代表着有150个样本每个样本有4个属性描述,species代表着这150个样本的分类.data=[meas(:,1),meas(:,2)];%在这里只取meas的第一列和第二列,即只选取前两个属性.groups=ismember(species,'setosa');%由于species分类中是有三个分类:setosa,versicolor,virginica,为了使问题简单,我们将其变为二分类问题:Setosaandnon-Setosa.[train,test]=crossvalind('holdOut',groups);cp=classperf(groups);%随机选择训练集合测试集[有关crossvalind的使用请自己help一下]其中cp作用是后来用来评价分类器的.svmStruct=svmtrain(data(train,:),groups(train),'showplot',true);%使用svmtrain进行训练,得到训练后的结构svmStruct,在预测时使用.训练结果如图:tu2HYPERLINK"http://www.ilovematlab.cn/attachment.php?aid=24863&k=d5871b5f3333ec8c873d178965ef6484&t=1263976450&nothumb=yes"\t"_blank"2.jpg(26.86KB)2009-5-1219:50classes=svmclassify(svmStruct,data(test,:),'showplot',true);%对于未知的测试集进行分类预测,结果如图:tu3HYPERLINK"http://www.ilovematlab.cn/attachment.php?a