资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
edit svmtrainedit svmclassfyedit svmpredictfun cti on svm_struct, svln dex = svmtra in (tra ining, group names, vararg in)%SVMTRAIN trai ns a support vector mach ine classier% SVMStruct = SVMTRAIN(TRAINING,GROUPtra ins a support vector mach ine% classifier using data TRAINING taken from tw groups gven by GROUP% SVMStruct contains inf ormati on about the tra ined classifier that is% used by SVMCLASSIFY for classifcatio n. GROUPis a colu mn vector of% values of the same len gth as TRAINING that defi nes two groups.ach% eleme nt of GROUPspecifies the group the corresp on di ng rw of TRAINING% bel ongs to. GROUPca n be a nu meric vector, a stri ng array, or a cell% array of stri ngs. SVMTRAIN treats NaNs or empty str ings in GROUPis% missi ng values and ign ores the corresp onding rows of TRAINING.% SVMTRAIN(.,KERNE_FUNCTION,KFUN) allows you to specfy the ker nel% fun ctio n KFUN used to map the trai ning data into ker nel space. The% default kernel fun ctio n is the dot product. KFUN can be one of the% follow ing str ings or a fun cti on han dle:% li near Lin ear ker nel or dot product% quadratic Quadratic ker nel% po lyno mia l Fblyno mial ker nel (default order 3)% rbf Gaussia n Radial Basis Fun cti on ker nel% mlp Multilayer ferceptr on ker nel (default scale 1)% fun ctio n A ker nel fun cti on spedied using ,% for example KFUN, or an anonym ous fun cti on% A ker nel fun cti on must be of the form% fun ctio n K = KFUN(U, V)% The retur ned value, K, is a matrix of size M-by-N, where U and V have M% and N rows respectively. If KFUN is parameterized, you can use% anonym ous fun cti ons to capture the problem-depe ndent parameters. For% example, suppose that your ker nel fun ctio n is% fun ctio n k = kfun (u,v,p1,p2)% k = tan h(p1*(u*v)+p2);% % You can set values for pl and p2 and the n use an anonym ous fun ctio n: % (u,v) kfun (u,v,p1,p2).% SVMTRAIN(.,POLYORDER,ORDER) allows you to specify the order of a% polyno mial ker nel. The default orders 3.% SVMTRAIN(.,MLF_PARAMS,P1 P2) allows you to specfy the% parameters of the Multilayer Prceptro n (mlp) ker nel. The mlp kernel% requires two parameters, P and P2, where K = tan h(PI*U*V + P2) and P1% 0 and F2 0. Default values are P = 1 and P2 = -1.% SVMTRAIN(.,METHOD,METHOD) allow you to specify the method used% to find the separati ng hyperpla ne. Opti ons are% QP Use quadratic program ming (requires the Optimizatio n Toolbox)% LS Use least-squares method% If you have the Optimizati on Toolbox, the n the QPnethod is the default% method. If not, the only available method is LS.% SVMTRAIN(.,QUADPROG_OTS,OPTIONS) allows you to pass an OPTIONS% structure created usi ng OITIMSET to the QUADPROG fun ction whe n using% the QP method. See help optimset for more details.% SVMTRAIN(.,SHOWLOT,true), whe n usedw ith two-dime nsio nal data,% creates a plot of the grouped data and plots the separat ing line for% the classifier.% Example:% % Load the data and select features for clasficatio n% load fisheriris% data = meas(:,1), meas(:,2);% % Extract the Setosa class% groups = ismember(speciessetosa);% % Ran domly select tra ining and test sets% tra in, test = crossvali nd(holdOut,groups);% cp = classperf(groups);% % Use a lin ear support vector mach ine clasfeier% svmStruct = svmtrai n(data(tra in ,:),groups(trai nshowplot,true);% classes = svmclassfy(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, I nc.% $Revisio n: 1.1.12.1 $ $Date: 2004/12/24 20:43:35 $% Refere nces:% 1 Kecma n, V, Lear ning and Soft Computi ng,% MIT Press, Cambridge, MA. 2001.% 2 Suyke ns, J.A.K., Van Gestel, T., De Braba nter, J., De Moor, B.,% Van dewalle, J., Least Squares Support Vector Mach in es,% World Scie ntfic. Sin gapore, 2002.% Scholkopf, B., Smola, A.J., Lear ning Wh Ker nes,% MIT Press, Cambridge, MA. 2002.% SVMTRAIN(.,KFUNARGS,ARGS) allow you to pass additio nal% argume nts to ker nel fun cti ons.% set defaultsplotflag = false;qp_opts =;kfun args = ;setPoly = false; usePbly = false;setMLP= false; useMLP= false;if isempty(whch(quadprog)useQuadprog = true;elseuseQuadprog = fase;end% set default ker nel fun cti onkfun = li near_ker nel;% check in putsif n arg in 2error( nargchk(2,l nf, narg in)endnum optargs = n arg in -2;optargs = vararg in;% grp2idx sorts a nu meric group ing var asce nding, and a stri ng group ing% var by order of first occurre nee g,groupStri ng = grp2idx(group names); % check group s a vector - though char in puts special.if isvector(group names) & ischar(group names)error(Bio
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号