支持向量机matlab实现源代码.doc
《支持向量机matlab实现源代码.doc》由会员分享,可在线阅读,更多相关《支持向量机matlab实现源代码.doc(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精品文档,仅供学习与交流,如有侵权请联系网站删除edit svmtrain edit svmclassify edit svmpredict function svm_struct, svIndex = svmtrain(training, groupnames, varargin) %SVMTRAIN trains a support vector machine classifier % SVMStruct = SVMTRAIN(TRAINING,GROUP) trains a support vector machine % classifier using data TRAINING
2、taken from two groups given by GROUP. % SVMStruct contains information about the trained classifier that is % used by SVMCLASSIFY for classification. GROUP is a column vector of % values of the same length as TRAINING that defines two groups. Each % element of GROUP specifies the group the correspon
3、ding row of TRAINING % belongs to. GROUP can be a numeric vector, a string array, or a cell % array of strings. SVMTRAIN treats NaNs or empty strings in GROUP as % missing values and ignores the corresponding rows of TRAINING. % SVMTRAIN(.,KERNEL_FUNCTION,KFUN) allows you to specify the kernel % fun
4、ction KFUN used to map the training data into kernel space. The % default kernel function is the dot product. KFUN can be one of the % following strings or a function handle: % linear Linear kernel or dot product % quadratic Quadratic kernel % polynomial Polynomial kernel (default order 3) % rbf Gau
5、ssian Radial Basis Function kernel % mlp Multilayer Perceptron kernel (default scale 1) % function A kernel function specified using , % for example KFUN, or an anonymous function % A kernel function must be of the form % function K = KFUN(U, V) % The returned value, K, is a matrix of size M-by-N, w
6、here U and V have M % and N rows respectively. If KFUN is parameterized, you can use % anonymous functions to capture the problem-dependent parameters. For % example, suppose that your kernel function is % function k = kfun(u,v,p1,p2) % k = tanh(p1*(u*v)+p2); % You can set values for p1 and p2 and t
7、hen use an anonymous function: % (u,v) kfun(u,v,p1,p2). % SVMTRAIN(.,POLYORDER,ORDER) allows you to specify the order of a % polynomial kernel. The default order is 3. % SVMTRAIN(.,MLP_PARAMS,P1 P2) allows you to specify the % parameters of the Multilayer Perceptron (mlp) kernel. The mlp kernel % re
8、quires two parameters, P1 and P2, where K = tanh(P1*U*V + P2) and P1 % 0 and P2 0. Default values are P1 = 1 and P2 = -1. % SVMTRAIN(.,METHOD,METHOD) allows you to specify the method used % to find the separating hyperplane. Options are % QP Use quadratic programming (requires the Optimization Toolb
9、ox) % LS Use least-squares method % If you have the Optimization Toolbox, then the QP method is the default % method. If not, the only available method is LS. % SVMTRAIN(.,QUADPROG_OPTS,OPTIONS) allows you to pass an OPTIONS % structure created using OPTIMSET to the QUADPROG function when using % th
10、e QP method. See help optimset for more details. % SVMTRAIN(.,SHOWPLOT,true), when used with two-dimensional data, % creates a plot of the grouped data and plots the separating line for % the classifier. % Example: % % Load the data and select features for classification % load fisheriris % data = m
11、eas(:,1), meas(:,2); % % Extract the Setosa class % groups = ismember(species,setosa); % % Randomly select training and test sets % train, test = crossvalind(holdOut,groups); % cp = classperf(groups); % % Use a linear support vector machine classifier % svmStruct = svmtrain(data(train,:),groups(trai
12、n),showplot,true); % classes = svmclassify(svmStruct,data(test,:),showplot,true); % % See how well the classifier performed % classperf(cp,classes,test); % cp.CorrectRate % See also CLASSIFY, KNNCLASSIFY, QUADPROG, SVMCLASSIFY. % Copyright 2004 The MathWorks, Inc. % $Revision: 1.1.12.1 $ $Date: 2004
13、/12/24 20:43:35 $ % References: % 1 Kecman, V, Learning and Soft Computing, % MIT Press, Cambridge, MA. 2001. % 2 Suykens, J.A.K., Van Gestel, T., De Brabanter, J., De Moor, B., % Vandewalle, J., Least Squares Support Vector Machines, % World Scientific, Singapore, 2002. % 3 Scholkopf, B., Smola, A.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 支持 向量 matlab 实现 源代码
限制150内