svm c语言,svm(支持向量机)全解.ppt

本文介绍了如何使用SVM(支持向量机)进行二维坐标中的分类,并提供了Matlab工具箱的示例代码,包括训练、测试和结果显示。此外,还探讨了SVM的C语言编程,提到了两个开源库Libsvm和SVM-light,并展示了C语言进行分类器训练和预测的示例。最后,给出了SVM模型和参数结构的详细定义。
摘要由CSDN通过智能技术生成

svm(支持向量机)全解

4.在二维坐标中绘制SVM的训练和测试结果: svcplot(X,Y,ker,alpha,bias) 其中: X - 训练样本的输入特征 Y - 训练样本的标号 ker - 核函数 alpha - SVM的求解结果 bias - SVM的偏移量 ker=‘linear’; %选择线性核函数 [nsv alpha bias]=svc(trnx,trny,ker,10); %训练SVM svcplot(trnx,trny,ker,alpha, bias); %显示分类器效果 利用SVM的Matlab工具箱进行印签提取的示例程序 tstnum=1; for i=1:size(RGB,1) for j=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; else resIm(i,j)=0; end end end imshow(resIm); 利用SVM的Matlab工具箱进行印签提取的示例程序 三、SVM的C语言编程介绍 1.求解SVM的两个开源开发包: Libsvm: .tw/~cjlin SVM-light:http://ais.gmd.de/~thorsten/svm_light :: ... 2. 利用SVM的C语言程序直接进行分类器的训练和测试: 例: 1 1:67 2:66 3:72 4:72 5:59 6:71 7:54 8:67 9:79 -1 1:101 2:108 3:100 4:99 5:102 6:95 7:93 8:96 9:89 使用说明 训练结果 3. 利用SVM的C语言开发包编写自己的SVM分类器: svm_model *svm_train(const svm_problem *prob, const svm_parameter *param) double svm_predict(const svm_model *model, const svm_node *x) struct svm_problem{ int l; double *y; struct svm_node **x;}; struct svm_parameter{ int svm_type;int kernel_type; double degree;// for poly double gamma;// for poly/rbf/sigmoid double coef0;// for poly/sigmoid// these are for training only double cache_size; // in MB double eps;// stopping criteriadouble C; int nr_weight;int *weight_label; double* weight; // for C_SVC double nu;// for NU_SVC, ONE_CLASS, and NU_SVR double p;// for EPSILON_SVR int shrinking;// use the shrinking heuristics }; struct svm_node{ int index; double value;}; 1 1:-0.844335 2:-0.184362 3:0.046215 4:0.593243 5:0.140576 6:0.330716 7:0.172408 8:-0.105515 struct svm_model{ svm_parameter param;// parameter int nr_class;// number of classes int l;// tot

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值