数据挖掘之支持向量机分类实现
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进行归类
线性向量机实现
非线性向量机
(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进行归类
线性向量机实现
非线性向量机
相关文章推荐
- jboss信息安全
- http协议分析工具【转】
- (转).NET代码混淆实践
- vs2010安装的一些问题
- Spring学习(14)--- 基于Java类的配置Bean 之 @ImportResource & @Value 注解
- CSS简单理解与应用
- Windows平台分布式架构实践 - 负载均衡(下)
- 【iOS】屏幕适配之NSLayoutConstraint
- iOS的主要框架介绍
- iOS 往来--书面资料
- GRE写作必备句型
- Android sqlite 数据类型
- iOS-ui-normal_ui_control
- Redis与Memcached的区别
- @weakify与@strongify的装逼写法, 用宏实现计算一个可变参数列表的长度
- LINQ体验(14)——LINQ to SQL语句之存储过程 夺表
- Android锁屏后主Activity的onDestroy方法被调用导致黑屏问题解决方案
- JQuery EasyUI combobox动态添加option
- 设置AVD环境变量
- NYOJ 204 Coin Test