Matlab下核函数方法进行非线性分类

采用核函数方法对下列数据进行非线性分类。给出matlab具体代码,及采用训练样本进行测试得到的准确率结果。
x=[0 1 0 1 2 -1];y=[0 0 1 1 2 -1];z=[-1 1 1 -1 1 1];其中,(x,y)代表二维的数据点,z 表示相应点的类型属性。

 

运行代码:

data=[1,0;0,1;2,2;-1,-1;0,0;1,1]; 

groups=[1;1;1;1;-1;-1];

figure;

subplot(2,2,1);

Struct1 = svmtrain(data,groups,'Kernel_Function','quadratic''showplot',true);

classes1=svmclassify(Struct1,data,'showplot',true);

title('二次核函数');

CorrectRate1=sum(groups==classes1)/6

subplot(2,2,2);

Struct2 = svmtrain(data,groups,'Kernel_Function','rbf''RBF_Sigma',0.41,'showplot',true);

classes2=svmclassify(Struct2,data,'showplot',true);

title('高斯径向基核函数(核宽0.41)');

CorrectRate2=sum(groups==classes2)/6

subplot(2,2,3);

Struct3 = svmtrain(data,groups,'Kernel_Function','polynomial''showplot',true);

classes3=svmclassify(Struct3,data,'showplot',true);

title('多项式核函数');

CorrectRate3=sum(groups==classes3)/6

subplot(2,2,4);

Struct4 = svmtrain(data,groups,'Kernel_Function','mlp''showplot',true);

classes4=svmclassify(Struct4,data,'showplot',true);

title('多层感知机核函数');

CorrectRate4=sum(groups==classes4)/6


运行结果:


  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值