1.最近结合ACO和SVM做分类,于是仔细看了下svmtrain的help文档。现结合该doc文档,做简单整理,希望对

svm入门者有点帮助哦。

svmtrain:用于训练支持向量机分类器。语法格式如下:

SVMStruct = svmtrain(Training, Group)

SVMStruct = svmtrain(..., 'Kernel_Function',

Kernel_FunctionValue, ...)

SVMStruct = svmtrain(..., 'RBF_Sigma',

RBFSigmaValue, ...)

SVMStruct = svmtrain(..., 'Polyorder',

PolyorderValue, ...)

SVMStruct = svmtrain(..., 'Mlp_Params',

Mlp_ParamsValue, ...)

SVMStruct = svmtrain(..., 'Method', MethodValue,

...)

SVMStruct = svmtrain(..., 'QuadProg_Opts',

QuadProg_OptsValue, ...)

SVMStruct = svmtrain(..., 'SMO_Opts',

SMO_OptsValue, ...)

SVMStruct = svmtrain(..., 'BoxConstraint',

BoxConstraintValue, ...)

SVMStruct = svmtrain(..., 'Autoscale',

AutoscaleValue, ...)

SVMStruct = svmtrain(..., 'Showplot',

ShowplotValue, ...)

解释如下:

Training是一个M行N列的矩阵,M是样本数,N是特征维数。Group:是个列向量,表示样本对应的类别,用字符串表示(可以用数字或单个字符)。

classifier is returned in SVMStruct, a structure with the

following fields. 'Kernel_Function',

Kernel_FunctionValue,.......'Showplot',

ShowplotValue这些在svmtrain中是可选项。他们在svmtrain中出现的顺序是无关紧要的。但必须成对出现,前面单引号里的是字符标记,后面给出的是对应的值。Kernel_FunctionValue

有如下些可选类别:

linear — Default. Linear kernel or dot product.

quadratic — Quadratic kernel.

rbf — Gaussian Radial Basis Function kernel with a default

scaling factor, sigma, of 1.

polynomial — Polynomial kernel with a default order of 3.

mlp — Multilayer Perceptron kernel with default scale and bias

parameters of [1, -1].

如可通过如下来设定核函数为Gaussian Radial Basis Function

kernel :

SVMStruct = svmtrain(Training, Group,

'Kernel_Function', rbf);

%%-------------------------分割线----------------------------------------------------------------------

2 svmtrain(

… );

%通过训练集来训练模型 svmpredict( …

);%对测试集进行预测 >>model

= svmtrain(train_label, train_matrix,

['libsvm_options']); -train_label: An m by 1 vector of training

labels (type must be

double).-train_matrix: An m by n matrix of m training

instances with n features. It can be dense or sparse

(type must be

double).-libsvm_options: A string of training options

in the same format as that of LIBSVM.===============The 'svmtrain'

function returns a model which can be used for

futureprediction. >>

[predicted_label, accuracy, decision_values/prob_estimates] =

svmpredict(test_label, test_matrix, model,

['libsvm_options']); -test_label: An m by 1 vector of prediction

labels. If labels of test data are unknown, simply use

any random values. (type must be

double)-testmatrix: An m by n matrix of m testing

instances with n features. It can be dense or sparse.

(type must be double)-model: The output of

svmtrain.-libsvm_options: A string of testing options in

the same format as that of

LIBSVM.=============== English:libsvm_options:-s

svm_type : set type of SVM (default 0)0 -- C-SVC1 -- nu-SVC2 --

one-class SVM3 -- epsilon-SVR4 -- nu-SVR-t kernel_type : set type

of kernel function (default 2)0 -- linear: u'*v1 -- polynomial:

(gamma*u'*v + coef0)^degree2 -- radial basis function:

exp(-gamma*|u-v|^2)3 -- sigmoid: tanh(gamma*u'*v + coef0)4 --

precomputed kernel (kernel values in training_instance_matrix)-d

degree : set degree in kernel function (default 3)-g gamma : set

gamma in kernel function (default 1/k)-r coef0 : set coef0 in

kernel function (default 0)-c cost : set the parameter C of C-SVC,

epsilon-SVR, and nu-SVR (default 1)-n nu : set the parameter nu of

nu-SVC, one-class SVM, and nu-SVR (default 0.5)-p epsilon : set the

epsilon in loss function of epsilon-SVR (default 0.1)-m cachesize :

set cache memory size in MB (default 100)-e epsilon : set tolerance

of termination criterion (default 0.001)-h shrinking: whether to

use the shrinking heuristics, 0 or 1 (default 1)-b

probability_estimates: whether to train a SVC or SVR model for

probability estimates, 0 or 1 (default 0)-wi weight: set the

parameter C of class i to weight*C, for C-SVC (default 1)-v n:

n-fold cross validation

mode==========================================================Chinese:Options:可用的选项即表示的涵义如下  -s

svm类型:SVM设置类型(默认0)  0 -- C-SVC  1 --v-SVC  2 – 一类SVM  3 -- e

-SVR  4 -- v-SVR  -t 核函数类型:核函数设置类型(默认2)  0 – 线性:u'v  1 – 多项式:(r*u'v

+ coef0)^degree  2 – RBF函数:exp(-r|u-v|^2)  3 –sigmoid:tanh(r*u'v +

coef0)  -d degree:核函数中的degree设置(针对多项式核函数)(默认3)  -g

r(gama):核函数中的gamma函数设置(针对多项式/rbf/sigmoid核函数)(默认1/ k)  -r

coef0:核函数中的coef0设置(针对多项式/sigmoid核函数)((默认0)  -c cost:设置C-SVC,e

-SVR和v-SVR的参数(损失函数)(默认1)  -n nu:设置v-SVC,一类SVM和v- SVR的参数(默认0.5)  -p

p:设置e -SVR 中损失函数p的值(默认0.1)  -m

cachesize:设置cache内存大小,以MB为单位(默认40)  -e eps:设置允许的终止判据(默认0.001)  -h

shrinking:是否使用启发式,0或1(默认1)  -wi

weight:设置第几类的参数C为weight?C(C-SVC中的C)(默认1)  -v n:

n-fold交互检验模式,n为fold的个数,必须大于等于2  其中-g选项中的k是指输入数据中的属性数。option -v

随机地将数据剖分为n部分并计算交互检验准确度和均方根误差。以上这些参数设置可以按照SVM的类型和核函数所支持的参数进行任意组合,如果设置的参数在函数或SVM类型中没有也不会产生影响,程序不会接受该参数;如果应有的参数设置不正确,参数将采用默认值。

%%-------------------------分割线----------------------------------------------------------------------

3.有时需要将变量转化为字符形式,这个很有用的,这个时候就需要记住num2str(variable,precison)哦。

例如:

用svm时,model=svmtrain(Lables,constants,'-c 1 -g 10')

为了可以用循环来调试到一个好的参数,可以用num2str这个函数将变量转化为字符型。

a=0.8, b=10,

cmd=['-c',' ',num2str(a),' ','-g',' ',num2str(b)];%这里'

'是为了空格

model=svmstrain(Labels,constant,cmd);

%%-------------------------分割线----------------------------------------------------------------------

4.svm一点资料

matlab的train函数用法,SVMtrain函数用法相关推荐

  1. matlab中libsvm的svmtrain函数用法

    这里的LIBSVM是一个由台湾大学林智仁(Lin Chih-Jen)教授等开发的SVM模式识别与回归的软件包,使用简单,功能强大,本文主要介绍其在Matlab中的使用. 注意不是matlab自带的sv ...

  2. matlab中bitget函数用法_Matlab函数大全

    目录 1.时间日期函数................................ ................................ ....................... ...

  3. MATLAB中var函数,mean函数的含义及用法详细解释

    MATLAB中var函数,mean函数的含义及用法详细解释 var函数语句 我们先来看var函数,MATLAB命令窗输入help var ,可以得到用到方差函数Syntax有: V = var(X); ...

  4. Matlab—绘图保存为视频VideoWrite()函数用法与自定义视频尺寸

    Matlab-绘图保存为视频VideoWrite()函数用法与自定义视频尺寸 1.早期版本的avifile()函数 Matlab中提供了将显示图形保存成视频的功能.早期的版本使用函数avifile() ...

  5. Matlab在算法中进行数字比较常用Max函数及Find函数的组合用法

    Matlab之max()函数 : max函数意思是返回数组中最大元素. 为了做清晰对比,展示一行多列及多行多列两个一维数组的例子: 1.一行多列(即:向量,向量就是只有一行或者一列的特殊矩阵): &g ...

  6. matlab sscanf用法,sscanf函数的用法

    木之叶舞 - 三级 2009-7-29 02:05 int型的数也会被转成字符型的,比如你输入的是程序名 123 那么argc=2,argv[1]="123".你可以用atoi或者 ...

  7. Matlab中print, fprint, fscanf, disp函数的用法

    最近一直在用python,导致学习的一些函数就有点混淆,趁着这会儿看代码,就再回顾下Matlab中print, fprint, fscanf, disp函数的用法 一.print() 函数可以把函数图 ...

  8. matlab stepwise 用法,matlabstepwise函数

    综合起来看,以上回归结果(回归函数.拟合曲线或曲面)近乎完美. (二)逐步回归假设已有数据 X 和 Y,在 Matlab 软件包中,使用 stepwise 命令进行逐步回 归,得到...... 是事先 ...

  9. matlab clabel函数用法,CLabel的用法 | 学步园

    DDX_Control(pDX, IDC_STATIC_CONNSTATE, m_labConnState); IDC_STATIC_CONNSTATE  是某静态控件的ID,设置这个静态控件的控制变 ...

最新文章

  1. ngModel 值不更新/显示
  2. UVa1368 - DNA Consensus String(贪心算法)
  3. java7新特性之Try-with-resources statement
  4. nginx $document_uri 参数使用
  5. 组合的示例代码 java_java实现Composite组合模式的实例代码
  6. 撰写paper时,如何在word里输入图片或其他文献(PDF)里的公式?(更新时间2022.03.01)
  7. java 自动加载jar_JAVA 动态(手动)加载jar文件
  8. 题解 P3978 【[TJOI2015]概率论】
  9. shell脚本中定义路径变量出现的BUG
  10. 坚持,对于一件事的坚持
  11. 李宏毅机器学习课程---1、机器学习介绍
  12. 【工具】telnet用法
  13. 中台服务架构的一点思考
  14. java9推迟_甲骨文宣布Java 9将会推迟到明年7月发布
  15. mysql按照首字母排序
  16. 【普通人VS程序员】电脑还可以这样关机,神操作,学到了学到了~(爆赞)
  17. Win7下调出任务快捷栏
  18. RH Timer for Mac(定时器软件)
  19. 安全面试之基础总结篇【超详细!】
  20. 如何修改Moodle上传文件大小的限制

热门文章

  1. react 生命周期
  2. Java 动态数据源配置
  3. [个人笔记][遗传算法] 遗传算法的python实现
  4. Lustre(待修正)
  5. 计算机应用基础试题及答案电大百度云,电大《计算机应用基础》试题及参考答案...
  6. oracle 数据字典画报,oracle privilege不得不说的11一个数据字典视图
  7. CUDA编程 | Pytorch-CUDA从入门到放弃
  8. 网络代理导致浏览器的问题解决方法
  9. 1、已知:1公里=2里=1000米,请编写一个程序,输入公里数,将其转换成里和米。要求程序的输入输出如下: 请输入公里数: 3.3 3.30公里=6.60里=3300米
  10. 米筐量化如何安装使用?