您的位置:首页 > 其它

数据挖掘之支持向量机分类实现

2015-07-07 17:29 453 查看
线性支持向量机和非线性支持向量机MATLAB实现

(1)Linear classification和nonLinear classification

clear all;

close all;

clc;

sp=[3 7;6 6;4 6;5 6.5];

nsp=size(sp);%sp的维度

sn=[1 2;3 5;7 3;3 4;6 2.7];

nsn=size(sn);

sd=[sp;sn];%将sp和sn合为一个数组,9*2

lsd=[true true true true false false true true false];%这是自己分的类

Y=nominal(lsd);

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)

%sumStruce=svmtrain(sd,Y,'showplot',true);% 线性实现

%svmStruct=svmtrain(sd,Y,'Kernel_Function','quadratic','showplot',true);%非线性实现

% RD=svmclassify(svmStruct,sd,'showplot',true);%用来对数组sd进行归类

线性向量机实现

非线性向量机
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: