支持向量机

  • C9_328151
    了解作者
  • 3.2KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-03-31 03:53
    上传日期
利用支持向量机对图像进行分类识别,有较好的识别率
SVM.rar
  • fun.m
    3.8KB
  • svm.m
    4.7KB
内容介绍
clear all; close all; %%%%%%%%%%%%%%%%%%数据%%%%%%%%%%%%%%%%%%%%% x1(1,1)=5.1418; x1(1,2)=0.5950; x1(2,1)=5.5519; x1(2,2)=3.5091; x1(3,1)=5.3836; x1(3,2)=2.8033; x1(4,1)=3.2419; x1(4,2)=3.7278; x1(5,1)=4.4427; x1(5,2)=3.8981; x1(6,1)=4.9111; x1(6,2)=2.8710; x1(7,1)=2.9259; x1(7,2)=3.4879; x1(8,1)=4.2018; x1(8,2)=2.4973; x1(9,1)=4.7629; x1(9,2)=2.5163; x1(10,1)=2.7118; x1(10,2)=2.4264; x1(11,1)=3.0470; x1(11,2)=1.5699; x1(12,1)=4.7782; x1(12,2)=3.3504; x1(13,1)=3.9937; x1(13,2)=4.8529; x1(14,1)=4.5245; x1(14,2)=2.1322; x1(15,1)=5.3643; x1(15,2)=2.2477; x1(16,1)=4.4820; x1(16,2)=4.0843; x1(17,1)=3.2129; x1(17,2)=3.0592; x1(18,1)=4.7520; x1(18,2)=5.3119; x1(19,1)=3.8331; x1(19,2)=0.4484; x1(20,1)=3.1838; x1(20,2)=1.4494; x1(21,1)=6.0941; x1(21,2)=1.8544; x1(22,1)=4.0802; x1(22,2)=6.2646; x1(23,1)=3.0627; x1(23,2)=3.6474; x1(24,1)=4.6357; x1(24,2)=2.3344; x1(25,1)=5.6820; x1(25,2)=3.0450; x1(26,1)=4.5936; x1(26,2)=2.5265; x1(27,1)=4.7902; x1(27,2)=4.4668; x1(28,1)=4.1053; x1(28,2)=3.0274; x1(29,1)=3.8414; x1(29,2)=4.2269; x1(30,1)=4.8709; x1(30,2)=4.0535; x1(31,1)=3.8052; x1(31,2)=2.6531; x1(32,1)=4.0755; x1(32,2)=2.8295; x1(33,1)=3.4734; x1(33,2)=3.1919; x1(34,1)=3.3145; x1(34,2)=1.8009; x1(35,1)=3.7316; x1(35,2)=2.6421; x1(36,1)=2.8117; x1(36,2)=2.8658; x1(37,1)=4.2486; x1(37,2)=1.4651; x1(38,1)=4.1025; x1(38,2)=4.4063; x1(39,1)=3.9590; x1(39,2)=1.3024; x1(40,1)=1.7524; x1(40,2)=1.9339; x1(41,1)=3.4892; x1(41,2)=1.2457; x1(42,1)=4.2492; x1(42,2)=4.5982; x1(43,1)=4.3692; x1(43,2)=1.9794; x1(44,1)=4.1792; x1(44,2)=0.4113; x1(45,1)=3.9627; x1(45,2)=4.2198; x2(1,1)=9.7302; x2(1,2)=5.5080; x2(2,1)=8.8067; x2(2,2)=5.1319; x2(3,1)=8.1664; x2(3,2)=5.2801; x2(4,1)=6.9686; x2(4,2)=4.0172; x2(5,1)=7.0973; x2(5,2)=4.0559; x2(6,1)=9.4755; x2(6,2)=4.9869; x2(7,1)=9.3809; x2(7,2)=5.3543; x2(8,1)=7.2704; x2(8,2)=4.1053; x2(9,1)=8.9674; x2(9,2)=5.8121; x2(10,1)=8.2606; x2(10,2)=5.1095; x2(11,1)=7.5518; x2(11,2)=7.7316; x2(12,1)=7.0016; x2(12,2)=5.4111; x2(13,1)=8.3442; x2(13,2)=3.6931; x2(14,1)=5.8173; x2(14,2)=5.3838; x2(15,1)=6.1123; x2(15,2)=5.4995; x2(16,1)=10.4188; x2(16,2)=4.4892; x2(17,1)=7.9136; x2(17,2)=5.2349; x2(18,1)=11.1547; x2(18,2)=4.4022; x2(19,1)=7.7080; x2(19,2)=5.0208; x2(20,1)=8.2079; x2(20,2)=5.4194; x2(21,1)=9.1078; x2(21,2)=6.1911; x2(22,1)=7.7857; x2(22,2)=5.7712; x2(23,1)=7.3740; x2(23,2)=2.3558; x2(24,1)=9.7184; x2(24,2)=5.2854; x2(25,1)=6.9559; x2(25,2)=5.8261; x2(26,1)=8.9691; x2(26,2)=4.9919; x2(27,1)=7.3872; x2(27,2)=5.8584; x2(28,1)=8.8922; x2(28,2)=5.7748; x2(29,1)=9.0175; x2(29,2)=6.3059; x2(30,1)=7.0041; x2(30,2)=6.2315; x2(31,1)=8.6396; x2(31,2)=5.9586; x2(32,1)=9.2394; x2(32,2)=3.3455; x2(33,1)=6.7376; x2(33,2)=4.0096; x2(34,1)=8.4345; x2(34,2)=5.6852; x2(35,1)=7.9559; x2(35,2)=4.0251; x2(36,1)=6.5268; x2(36,2)=4.3933; x2(37,1)=7.6699; x2(37,2)=5.6868; x2(38,1)=7.8075; x2(38,2)=5.0200; x2(39,1)=6.6997; x2(39,2)=6.0638; x2(40,1)=5.6549; x2(40,2)=3.6590; x2(41,1)=6.9086; x2(41,2)=5.4795; x2(42,1)=7.9933; x2(42,2)=3.3660; x2(43,1)=5.9318; x2(43,2)=3.5573; x2(44,1)=9.5157; x2(44,2)=5.2938; x2(45,1)=7.2795; x2(45,2)=4.8596; x2(46,1)=5.5233; x2(46,2)=3.8697; x2(47,1)=8.1331; x2(47,2)=4.7075; x2(48,1)=9.7851; x2(48,2)=4.4175; x2(49,1)=8.0636; x2(49,2)=4.1037; x2(50,1)=8.1944; x2(50,2)=5.2486; x2(51,1)=7.9677; x2(51,2)=3.5103; x2(52,1)=8.2083; x2(52,2)=5.3135; x2(53,1)=9.0586; x2(53,2)=2.9749; x2(54,1)=8.2188; x2(54,2)=5.5290; x2(55,1)=8.9064; x2(55,2)=5.3435; for i=1:45 r1(i)=x1(i,1);end; for i=1:45 r2(i)=x1(i,2);end; for i=1:55 r3(i)=x2(i,1);end; for i=1:55 r4(i)=x2(i,2);end; figure(1); plot(r1,r2,'*',r3,r4,'o'); axis([0,12,0,8]); for i=1:45 x(i,1)=x1(i,1); x(i,2)=x1(i,2); y(i,1)=1; end; for i=1:55 x(i+45,1)=x2(i,1); x(i+45,2)=x2(i,2); y(i+45,1)=-1; end; X=[x]; %样本向量 Y=[y]; a0=zeros(100,1); %初始值 A=[];b=[]; %无线性不等式约束 Aeq=Y';beq=0; %线性等式约束 lb=zeros(100,1); %上下界约束 [a,fval]=fmincon('fun',a0,A,b,Aeq,beq,lb); w = X'*(a.*Y) %支撑矢量 epsilon = 1e-5; %计算w0 index = find(a > epsilon); sum=0; for i=1:length(index) j=index(i); sum=sum+1/y(j) - X(j,:)*w; end b0 =(1/length(index))*sum; %作出分类线 h=gca; XLim=get(h,'Xlim'); YLim=-XLim*w(1)/w(2)-b0/w(2);%w*x+b=0,即w(1)x(1)+w(2)x(2)+b=0,x(1)=xlim,x(2)=ylim h=line([XLim(1),XLim(2)],[YLim(1),YLim(2)]); title('使用线性SVM算法设计的分类器'); set(h,'color','k');
评论
    相关推荐
    • 支持向量机
      利用支持向量机实现分类,包括对支持向量机的详细描述及应用。
    • 葡萄酒支持向量机SVM分类
      采用支持向量机SVM分类葡萄酒,完整代码,无错误,下载即可运行。
    • 支持向量机实现的分类源码
      支持向量机实现的分类源码,可用来实现数据分类
    • 支持向量机-libsvm
      libsvm是台湾大学做的开源代码,svm的方法很全,而且提供了参数的选择方法。对于做分类,做识别的同学应该很有用处
    • 支持向量机用于分类
      改代码为机器学习中的支持向量机算法,主要用于分类任务
    • 支持向量机分类识别代码
      支持向量机分类识别代码支持向量机分类识别代码支持向量机分类识别代码支持向量机分类识别代码支持向量机分类识别代码支持向量机分类识别代码支持向量机分类识别代码
    • 基于bow的支持向量机分类
      这是一个图像分类的程序,可用于多种图像分类
    • matlab代码不反应-Classification-SVM:分类支持向量机
      matlab代码不React分类支持向量机 在四个数据集上使用最小二乘回归进行多类分类 选择数据集的过程 在选择用于应用机器学习的数据集时,重要的是对高质量,真实世界(非人为)的数据集进行练习。 幸运的是,UCI机器...
    • 支持向量机
      malab开发的svm程序,有注释,可画出分类
    • SIM800C_MQTT.rar
      使用SIM800C模块,使用MQTT协议,连接中国移动onenet平台,能实现数据的订阅、发布、存储等