svm(上)支持向量机课件

上传人:我*** 文档编号:134469205 上传时间:2020-06-05 格式:PPT 页数:44 大小:4.10MB
返回 下载 相关 举报
svm(上)支持向量机课件_第1页
第1页 / 共44页
svm(上)支持向量机课件_第2页
第2页 / 共44页
svm(上)支持向量机课件_第3页
第3页 / 共44页
svm(上)支持向量机课件_第4页
第4页 / 共44页
svm(上)支持向量机课件_第5页
第5页 / 共44页
点击查看更多>>
资源描述

《svm(上)支持向量机课件》由会员分享,可在线阅读,更多相关《svm(上)支持向量机课件(44页珍藏版)》请在金锄头文库上搜索。

1、SupportVectorMachines 支持向量机 第三讲 引子 2 3 相关参考资料 统计学习理论的本质 VladimirN Vapnik著 张学工译 清华大学出版社 2000 09 4 www kernel machines orgwww support BernhardScholkopf AlexJ Smola CHRISTOPHERJ C BURGES 支持向量机导论 N Cristianini J Shawe Taylor著 电子工业出版社 2004 03SupportVectorClassification StevenGunn 518 54 29 模式识别领域权威期刊与会议

2、IEEETrans PatternAnalysisandMachineIntelligenceIEEETrans NeuralNetworks IEEEConferenceonComputerVisionandPatternRecognition CVPR InternationalConferenceonPatternRecognition ICPR InternationalConferenceonComputerVision ICCV 支持向量机的应用之一 手写体数字识别 1 支持向量机可以做什么 NIST手写体数字的前100个 目前最好的识别水平 LeNet4多项式支持向量机 错误率

3、0 7 6 错误率 0 8 1 支持向量机可以做什么 支持向量机的应用之二 性别识别 7 1 支持向量机可以做什么 支持向量机的应用之三 行人检测 8 2 支持向量机的提出 问题1 支持向量机为什么会有如此好的性能 问题2 何为最优分类面 9 它追求的不仅仅是得到一个能将两类样本分开的分类面 而是要得到一个最优的分类面 TobeNo 1 2 支持向量机的提出 参考标准 使错分样本数目最少 缺陷1 错分训练样本数目对判别函数的好坏评估不够精细 错分样本数最少 错分训练样本数最少 10 缺陷2 拥有较少的错分训练样本数的判别函数未必就是一个好的判别函数 2 支持向量机的提出 11 margin 2

4、 支持向量机的提出 支持向量机的标准 使margin尽可能大 两类样本到分类面的最短距离之和 12 a 线性支持向量机的数学模型 3 支持向量机的数学模型 设所求的分类面表达式为 该分类面若能将训练样本线性分开 则 13 对于有限个数的样本 存在 上式可简写为 在上述约束条件下 SVM的求解则是最大化margin的过程 问题 若将分类面 w b 对应的margin记为 则 14 优化目标 约束条件 利用线性SVM求解线性分类面本质上是求解如下优化问题 15 综上所述 线性SVM的数学模型可以描述为 给定训练样本集 b 支持向量机的求解 16 支持向量机的优化模型 一般的优化问题模型 Step1

5、 构造Lagrange函数 Step2 求解Lagrange函数的鞍点 求解L w b 关于w和b的最小值 关于 的最大值 即 Lagrange乘子 b 支持向量机的求解 拉格朗日对偶法 17 Step3代入Lagrange函数 得到原始问题的对偶问题 对L w b 关于w和b求偏导 得 18 19 原始问题与对偶问题解的关系 原始问题 对偶问题 20 支持向量机的判别函数 Karush Kuhn Tucker KKT 条件与支持向量 对于这样的样本 我们称为支持向量 SupportVectors KKT条件 21 对偶问题的解是最优解的条件 最优超平面是支持向量的线性组合 SVM的解的表达式

6、可以重写为 支持向量机的判别函数 22 SupportVectorMachine 支持向量机的编程实现 23 一 Matlab图像编程概要 1 读入图像 RGB imread 1 jpg 该函数的返回值RGB是一个三维的数组 分别代表像素点所在的行号 列号和像素点的R G B三个通道的值 例 RGB 1 1 1 图像第一行第一列的R值 RGB 1 3 2 图像第一行第三列的G值 RGB 2 4 3 图像第二行第四列的B值 RR RGB 1 彩色图像的红色像素通道GG RGB 2 彩色图像的绿色像素通道BB RGB 3 彩色图像的蓝色像素通道 2 鼠标输入 xx yy button ginput

7、 接受鼠标输入直到敲回车键结束 其中 xx yy 记录鼠标按下时横坐标和纵坐标值 button 记录鼠标按下时的状态 1表示左键 2表示中间键 3表示右键 3 绘制图形 plot x y b plot x y b 在坐标 x y 处绘制一个蓝色的 注意 进行图形绘制前 首先运行figure 如果要绘制多个点 需要首先运行holdon 等绘制结束 再运行holdoff xlabel R ylabel G holdoff count asd size xx subplot 1 2 2 holdon fori 1 counttrnx i RR yy i xx i GG yy i xx i switc

8、hbutton i case1trny i 1 plot trnx i 1 trnx i 2 r case2trny i 1 plot trnx i 1 trnx i 2 b otherwiseendend 利用Matlab在图像上采集训练样本的示例程序 Figure subplot 1 2 1 imshow S3a bmp Title 鼠标左键点印章 鼠标右键点纸面 回车结束 xx yy button ginput RGB imread S3a bmp RR RGB 1 GG RGB 2 BB RGB 3 1 训练SVM nsv alpha b0 svc X Y ker C 二 SVM的Ma

9、tlab工具箱使用指南 X 训练样本的输入特征 X的行数为训练样本的个数 X的列数代表训练样本的特征维数 Y 训练样本对应的标号 为一个列矩阵 矩阵的行数为样本的个数 Y的值只能是1或者 1 Ker 核函数类型 常用的包括 linear poly rbf C 经验风险与结构风险的权衡参数 详见SVM的数学优化模型 nsv 支持向量的个数 alpha 对偶问题的解 b0 svm表达式中的偏移量 2 测试SVM preY svcoutput trnX trnY tstX ker alpha bias trnX 训练样本的输入特征 trnY 训练样本的标号 tstX 测试样本的输入特征 ker 核函

10、数alpha SVM的求解结果bias SVM的偏移量 svkernel m 3 核函数参数的设置 switchlower ker case linear k u v case poly p1 2 k u v 1 p1 case rbf p1 1 k exp u v u v 2 p1 2 case sigmoid p1 1 p2 1 k tanh p1 u v length u p2 otherwisek u v end 4 在二维坐标中绘制SVM的训练和测试结果 svcplot X Y ker alpha bias 其中 X 训练样本的输入特征Y 训练样本的标号ker 核函数alpha SV

11、M的求解结果bias SVM的偏移量 ker linear 选择线性核函数 nsvalphabias svc trnx trny ker 10 训练SVMsvcplot trnx trny ker alpha bias 显示分类器效果 利用SVM的Matlab工具箱进行印签提取的示例程序 tstnum 1 fori 1 size RGB 1 forj 1 size RGB 2 testx double RGB i j 1 2 preY svcoutput trnx trny testx ker alpha bias tstnum tstnum 1 if preY 1 resIm i j 255

12、 elseresIm i j 0 endendendimshow resIm 利用SVM的Matlab工具箱进行印签提取的示例程序 三 SVM的C语言编程介绍 1 求解SVM的两个开源开发包 Libsvm http www csie ntu edu tw cjlinSVM light http ais gmd de thorsten svm light 2 利用SVM的C语言程序直接进行分类器的训练和测试 例 11 672 663 724 725 596 717 548 679 79 11 1012 1083 1004 995 1026 957 938 969 89 使用说明 训练结果 3 利

13、用SVM的C语言开发包编写自己的SVM分类器 svm model svm train constsvm problem prob constsvm parameter param doublesvm predict constsvm model model constsvm node x structsvm problem intl double y structsvm node x structsvm parameter intsvm type intkernel type doubledegree forpolydoublegamma forpoly rbf sigmoiddoubleco

14、ef0 forpoly sigmoid thesearefortrainingonlydoublecache size inMBdoubleeps stoppingcriteriadoubleC intnr weight int weight label double weight forC SVCdoublenu forNU SVC ONE CLASS andNU SVRdoublep forEPSILON SVRintshrinking usetheshrinkingheuristics structsvm node intindex doublevalue 11 0 8443352 0

15、1843623 0 0462154 0 5932435 0 1405766 0 3307167 0 1724088 0 105515 structsvm model svm parameterparam parameterintnr class numberofclassesintl total SVsvm node SV SVs SV l double sv coef coefficientsforSVsindecisionfunctionsdouble rho constantsindecisionint label labelofeachclass label n int nSV num

16、berofSVsforeachclass nSV n intfree sv 1ifsvm modeliscreatedbysvm load model 0ifsvm modeliscreatedbysvm train svm typec svckernel typelinearnr class2total sv239rho0 672633label1 1nr sv119120SV11 0 8443352 0 1843623 0 0462154 0 5932435 0 1405766 0 3307167 0 1724088 0 10551511 2 1233962 0 3094693 0 7695124 1 2201155 0 6924396 1 8781237 1 3675968 0 999905 0 1851 1 1411082 0 4098973 0 5737544 0 0336295 1 8326386 0 7093447 0 3618058 1 040870 3991 1 529852 0 0345753 0 6770824 1 2873735 0 6924396 0 1658

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > PPT模板库 > PPT素材/模板

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号