S vmtrain:训练SVM分类器

Svmclassify:使用训练好的SVM分类器进行分类

1. >>help svmtrain

SVMStruct = svmtrain(Training,Group,Name,Value)
trains a support vector machine (SVM) classifier on data taken from two groups. TRAINING is a numeric matrix of predictor data(TRAINING是预测数据的一个数阵). Rows of TRAINING correspond to observations(TRAINING的行数代表样本数); columns correspond to features(列数代表特征的维数). Y is a column vector that contains the known class labels for TRAINING(Y是列向量,里面存着TRAINING的分类标签). Y is a grouping variable, i.e., it can be a categorical, numeric, or logical vector; a cell vector of strings; or a character matrix with each row representing a class label (see help for groupingvariable). Each element of Y specifies the group the corresponding row of TRAINING belongs to. TRAINING and Y must have the same number of rows. (Name:参数名称;Value:相应的值;[...‘name1’,‘value1’,‘name2’,‘value2’...])SVMSTRUCT contains information about the trained classifier, including the support vectors, that is used by SVMCLASSIFY for classification(SVMSTRUCT结构体中包含了训练好的分类器的所有参数,包括支持向量,这些支持向量也用于对测试集进行分类). svmtrain treats NaNs, empty strings or 'undefined' values as missing values and ignores the corresponding rows in TRAINING and Y.

2.分类机的参量选择svmtrain

************************************************************************

'kernel_function'  A string or a function handle specifying the kernel function used to represent the dot product  in a new space. The value can be one of the following:
 'linear'  - Linear kernel or dot product (default). In this case, svmtrain finds the optimal separating plane in the original space.
 'quadratic'  - Quadratic kernel(二次核函数)
 'polynomial' - Polynomial kernel with default order 3. To specify another order, use the 'polyorder' argument.(多项式核函数,默认是3阶,如果需要提升,在‘polyorder’进行参数设置)
 'rbf' - Gaussian Radial Basis Function with default scaling factor 1. To  specify another scaling factor,  use the 'rbf_sigma' argument.(高斯径向核函数,默认核宽为1,在‘rbf_sigma’可以进行参数设置)
 'mlp' - Multilayer Perceptron kernel (MLP) with default weight 1 and default bias -1. To specify another weight or bias, use the 'mlp_params' argument.(多层感知核函数,默认权重1,偏好-1)

**************************************************************************************************************************

'rbf_sigma' A positive number specifying the scaling factor in the Gaussian radial basis function kernel. Default is 1.(设置高斯径向核函数的核宽)
**************************************************************************************************************************
'polyorder' A positive integer specifying the order of the polynomial kernel. Default is 3.(设置多项式核函数的阶数)
**************************************************************************************************************************
'mlp_params'  A vector [P1 P2] specifying the parameters of MLP kernel.  The MLP kernel takes the form: K = tanh(P1*U*V' + P2), where P1 > 0 and P2 < 0. Default is [1,-1].(设置多层感知核函数的权重和偏好) 
***************************************************************************************************************************
'method' A string specifying the method used to find the separating hyperplane. Choices are:(采用指定的方法寻找分类超平面)
'SMO' - Sequential Minimal Optimization (SMO) method (default). It implements the L1 soft-margin SVM classifier.(序列最小优化算法)
'QP'  - Quadratic programming (requires an Optimization Toolbox license). It implements the L2 soft-margin SVM classifier. Method 'QP' doesn't scale well for TRAINING with large number of observations.(二次规划)
'LS'  - Least-squares method. It implements the L2 soft-margin SVM classifier.(最小平方方法)

***************************************************************************************************************************

 'options' Options structure created using either STATSET or OPTIMSET.* When you set 'method' to 'SMO' (default),create the options structure using STATSET. Applicable options:
'Display'  Level of display output.  Choices are 'off' (the default), 'iter', and 'final'. Value 'iter' reports every 500 iterations.
'MaxIter'  A positive integer specifying the maximum number of iterations allowed. Default is 15000 for method 'SMO'.
* When you set method to 'QP', create the options structure using OPTIMSET. For details of applicable options choices, see QUADPROG options. SVM uses a convex quadratic program,so you can choose the 'interior-point-convex' algorithm in QUADPROG.
**************************************************************************************************************************
'tolkkt' A positive scalar that specifies the tolerancewith which the Karush-Kuhn-Tucker (KKT) conditions are checked for method 'SMO'. Default is 1.0000e-003.(‘method’='SMO'时;KKT迭代收敛条件).
************************************************************************************************************************** 
'kktviolationlevel'   A scalar specifying the fraction of observations that are allowed to violate the KKT conditions for method 'SMO'. Setting this value to be positive helps the algorithm to converge faster if it is  fluctuating near a good solution. Default is 0.
************************************************************************************************************************** 
'kernelcachelimit'    A positive scalar S specifying the size of the  kernel matrix cache for method 'SMO'. The
algorithm keeps a matrix with up to S * S double-precision numbers in memory. Default is 5000. When the number of points in TRAINING exceeds S, the SMO method slows down. It's recommended to set S as large as your system permits.(核函数内存空间设置).
 ************************************************************************************************************************** 
'boxconstraint'  The box constraint C for the soft margin. C can be a positive numeric scalar or a vector of positive numbers with the number of elements equal to the number of rows in TRAINING.  Default is 1.
* If C is a scalar, it is automatically rescaled by N/(2*N1) for the observations of group one, and by N/(2*N2) for the observations of group two, where N1 is the number of observations in group one, N2 is the number of observations in group two. The rescaling is done to take into account unbalanced groups, i.e., when N1 and N2 are different.
 * If C is a vector, then each element of C specifies the box constraint for the corresponding observation.
************************************************************************************************************************** 
 'autoscale' A logical value specifying whether or not to shift and scale the data points before training.  When the value is true, the columns of TRAINING are shifted and scaled to have zero mean unit variance. Default is true(数据归一化。默认是打开的).
************************************************************************************************************************** 
'showplot' A logical value specifying whether or not to show a plot. When the value is true, svmtrain creates a plot of the grouped data and the separating line for the classifier, when using data with 2features (columns). Default is false(分类结果显示,仅适用于特征空间是两维情况).
 ********************************************************************************************

3.SVMSTRUCT中包含哪些信息?

SupportVectors  Matrix of data points with each row correspondingto a support vector(支持向量). 
Note: when 'autoscale' is false, this field contains original support vectors in TRAINING. When 'autoscale' is true, this field contains shifted and scaled vectors from TRAINING.
Alpha  Vector of Lagrange multipliers for the support vectors. The sign is positive for support vectors  belonging to the first group and negative for support vectors belonging to the second group(拉格朗日向量).
Bias  Intercept of the hyperplane that separates the two groups(超平面截距).
Note: when 'autoscale' is false, this field corresponds to the original data points in TRAINING. When 'autoscale' is true, this field corresponds to shifted and scaled data points.
KernelFunction  The function handle of kernel function used(核函数).
KernelFunctionArgs   Cell array containing the additional arguments for the kernel function(核函数参量).
GroupNames   A column vector that contains the known class labels for TRAINING. Y is a grouping variable (see help for groupingvariable).
SupportVectorIndices A column vector indicating the indices of support vectors.
ScaleData   This field contains information about auto-scale.When 'autoscale' is false, it is empty. When  'autoscale' is set to true, it is a structurecontaining two fields:
                         shift       - A row vector containing the negative
                                       of the mean across all observations
                                       in TRAINING.
                         scaleFactor - A row vector whose value is
                                       1./STD(TRAINING).
FigureHandles   A vector of figure handles created by svmtrain  when 'showplot' argument is TRUE.

4.默认形式&参数设置对比

默认形式:
[cpp] view plaincopy
  1. <span style="font-size:18px;">svmStruct = svmtrain(data(train,:),groups(train),'showplot',true);
  2. classes = svmclassify(svmStruct,data(test,:),'showplot',true);
  3. classperf(cp,classes,test);
  4. cp.CorrectRate;</span>
  

参数选择形式:

[cpp] view plaincopy
  1. <span style="font-size:18px;">svmStruct = svmtrain(data(train,:),groups(train),...
  2. <span style="white-space:pre;">   </span>    'Kernel_Function','rbf','RBF_Sigma',5,'showplot',true);
  3. classes = svmclassify(svmStruct,data(test,:),'showplot',true);
  4. classperf(cp,classes,test);
  5. cp.CorrectRate;</span>

注意:参数名称和后面的修改值必须要一一对应!

svmtrain/svmclassify参数说明相关推荐

  1. svmtrain返回参数说明

    libsvm中svmtrain返回参数 如果使用svmtrain函数的时候,输入参数中含有-v,选择交叉验证,那么函数返回值是一个值,表示的是交叉验证分类的正确率或者是回归的误差: 如果使用svmtr ...

  2. LibSVM学习(六)——easy.py和grid.py的使用(转)

    我们在"LibSVM学习(一)"中,讲到libSVM有一个tools文件夹,里面包含有四个python文件,是用来对参数优选的.其中,常用到的是easy.py和grid.py两个文 ...

  3. 高人对libsvm的经典总结(全面至极)

    http://www.ilovematlab.cn/viewthread.php?tid=74019&sid=vYpSs5 SVM相关资源汇总[matlab-libsvm-class-regr ...

  4. libSVM在matlab下的使用安装

    1) 从LIBSVM的官网http://www.csie.ntu.edu.tw/~cjlin/libsvm/上下载最新版本的LIBSVM,当前版本为libsvm-3.18.zip 2) 解压压缩包到电 ...

  5. libsvm——参数优化工具grid.py的使用

    工具grid.py主要通过交叉验证的方法求最优的核函数参数C和gamma. 参考来源:http://blog.csdn.net/flydreamgg/article/details/4470477 一 ...

  6. LibSVM学习详细说明

    原址:https://www.cnblogs.com/-ldzwzj-1991/p/5897199.html LibSVM是台湾林智仁(Chih-Jen Lin)教授2001年开发的一套支持向量机的库 ...

  7. matlab svmtrain和svmclassify函数使用示例

    监督式学习(Supervised Learning)常用算法包括:线性回归(Linear Regression).逻辑回归(Logistic Regression).神经网络(Neural Netwo ...

  8. svmtrain和svmclassify参数细说_核函数选择

    1. >>help svmtrain SVMSTRUCT = svmtrain(TRAINING, Y)  trains a support vector machine (SVM) cl ...

  9. svmtrain和svmpredict简介(转)

    本文主要介绍了SVM工具箱中svmtrain和svmpredict两个主要函数: (1)model= svmtrain(train_label, train_matrix, ['libsvm_opti ...

最新文章

  1. 搭建多语言外文网站需要注意三个细节问题
  2. 全球及中国成人病袍行业专项调研评估及未来发展趋势预测报告2021-2027年版
  3. Java爬虫技术(二)爬取京东iPhone商品信息并生成Json日志
  4. Python继承类的方式实现多线程及控制线程数
  5. the database profile could not loaded. Check log for details
  6. java中 t无法对齐,java – 即使X应匹配T,也无法将X转换为T?
  7. 本地存储和服务器存储
  8. 诗词乱拼 zz from smth.org
  9. win10打开谷歌浏览器chrome,并进入kiosk模式
  10. web开发入门,css背景图片自适应屏幕宽度
  11. 低依赖C++ GUI库imgui笔记
  12. GFD563A101 3BHE046836R0101
  13. Math数学方法,String字符串型、Date日期
  14. 阿里云服务器---排查挖矿病毒
  15. 【树模型与集成学习】(task2)代码实现CART树(更新ing)
  16. 基于DSP的数字图像处理(1)
  17. 以动物命名的软件品牌盘点
  18. 免填邀请码已经火了,你还在等什么
  19. 排名算法(二)--淘宝搜索排序算法分析
  20. 小程序分享自己的二维码 保存到相册

热门文章

  1. Apk打包、安装、签名
  2. vmware里的vista安装声卡
  3. 大火的华强北二代 AirPods 值不值得买?如何才能买到顶配呢?
  4. Kill Freaking LISF
  5. Python机器学习库
  6. 2018谷歌I/O开发者大会8大看点汇总 新品有哪些
  7. HFSS中金属接地板的理解
  8. 计算机基础与组成原理学习
  9. Java之Date类和Calendar类的区别
  10. Java实现小拼图游戏