📄 svmlight.html
字号:
<html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"> <title>svmlight.m</title><link rel="stylesheet" type="text/css" href="../../m-syntax.css"></head><body><code><span class=defun_kw>function</span> <span class=defun_out>model</span>=<span class=defun_name>svmlight</span>(<span class=defun_in>data,options</span>)<br><span class=h1>% SVMLIGHT Interface to SVM^{light} software.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Synopsis:</span></span><br><span class=help>% model = svmlight(data)</span><br><span class=help>% model = svmlight(data,options)</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Description:</span></span><br><span class=help>% This function serves as an interface between Matlab </span><br><span class=help>% and SVM^{light} (Version: 5.00) optimizer which trains </span><br><span class=help>% the Support Vector Machines classifier.</span><br><span class=help>%</span><br><span class=help>% The executable file 'svm_learn' must be in the path. </span><br><span class=help>% The SVM^{light} software can be downloaded from:</span><br><span class=help>% http://svmlight.joachims.org/</span><br><span class=help>%</span><br><span class=help>% This function creates temporary files 'tmp_alphaXX.txt', </span><br><span class=help>% 'tmp_examplesXX.txt', 'tmp_modelXX.txt' and 'tmp_verbXX.txt' for </span><br><span class=help>% comunication with the SVM^{light} software. The XX=datestr(now)</span><br><span class=help>% is string consisting of current date and time.</span><br><span class=help>% </span><br><span class=help>% <span class=help_field>Input:</span></span><br><span class=help>% data [struct] Labeled binary data:</span><br><span class=help>% .X [dim x num_data] Training vectors.</span><br><span class=help>% .y [1 x num_data] Labels of training data (1 or 2).</span><br><span class=help>% </span><br><span class=help>% options [struct] Control parameters:</span><br><span class=help>% .ker [string] Kernel identifier: </span><br><span class=help>% 'linear' (default),'rbf' and 'poly'. </span><br><span class=help>% .arg [1x1] Kernel argument (default []).</span><br><span class=help>% .C [1x1] SVM regularization constant (default C=inf).</span><br><span class=help>% .j [1x1] Cost-factor, by which training errors on </span><br><span class=help>% positive examples outweight errors on negative examples (default 1).</span><br><span class=help>% .eps [1x1] Tolerance of KKT-conditions (default eps=0.001).</span><br><span class=help>% .keep_files [1x1] If ==1 then keeps temporary files otherwise</span><br><span class=help>% erase them.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Output:</span></span><br><span class=help>% model [struct] Binary SVM classifier:</span><br><span class=help>% .Alpha [nsv x 1] Weights of support vectors.</span><br><span class=help>% .b [1x1] Bias of decision function.</span><br><span class=help>% .sv.X [dim x nsv] Support vectors.</span><br><span class=help>% .sv.inx [1 x nsv] Indices of SVs (model.sv.X = data.X(:,inx)).</span><br><span class=help>% .nsv [int] Number of Support Vectors.</span><br><span class=help>% .kercnt [int] Number of kernel evaluations used by the SVM^{light}.</span><br><span class=help>% .trnerr [real] Classification error on training data.</span><br><span class=help>% .margin [real] Margin of found classifier.</span><br><span class=help>% .options [struct] Copy of used options.</span><br><span class=help>% .cputime [real] Used CPU time in seconds.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Example:</span></span><br><span class=help>% data=load('riply_trn'); </span><br><span class=help>% model=svmlight(data,struct('ker','rbf','C',10,'arg',1))</span><br><span class=help>% figure; ppatterns(data); psvm(model);</span><br><span class=help>%</span><br><span class=help>% See also </span><br><span class=help>% SVMCLASS, XY2SVMLIGHT.</span><br><span class=help>%</span><br><hr><span class=help1>% <span class=help1_field>About:</span> Statistical Pattern Recognition Toolbox</span><br><span class=help1>% (C) 1999-2003, Written by Vojtech Franc and Vaclav Hlavac</span><br><span class=help1>% <a href="http://www.cvut.cz">Czech Technical University Prague</a></span><br><span class=help1>% <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a></span><br><span class=help1>% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a></span><br><br><span class=help1>% <span class=help1_field>Modifications:</span></span><br><span class=help1>% 09-feb-2006, VF, added date_str(findstr(date_str,':')) = '.'; based on</span><br><span class=help1>% M.Urban comment.</span><br><span class=help1>% 16-may-2004, VF</span><br><span class=help1>% 15-jan-2004, VF, handling argument of poly kernel repared</span><br><span class=help1>% 10-oct-2003, VF, computation of lin model added</span><br><span class=help1>% 29-aug-2003, VF, seconds are added to the name of temporary files</span><br><span class=help1>% 12-may-2003, VF, 1st 3 lines of verb_file are skiped</span><br><span class=help1>% 31-jan-2003, VF, added option 'j' </span><br><span class=help1>% 28-Jan-2003, VF</span><br><span class=help1>% 20-jan-2003, VF, temporary files are unique and are deleted at the end</span><br><span class=help1>% 14-Jan-2003, VF</span><br><span class=help1>% 26-sep-2002, VF</span><br><span class=help1>% 3-Jun-2002, V.Franc</span><br><br><hr>tic;<br><br>data=c2s(data);<br><br><span class=comment>% gets current date and time</span><br>date_str=datestr(now);<br>date_str(findstr(date_str,<span class=quotes>' '</span>)) = <span class=quotes>'-'</span>;<br>date_str(findstr(date_str,<span class=quotes>':'</span>)) = <span class=quotes>'.'</span>;<br>sec=clock;<br>date_str = [date_str <span class=quotes>'-'</span> num2str(sec(<span class=keyword>end</span>))];<br><br><br><span class=comment>% names of temporary files </span><br>examples_file = [<span class=quotes>'tmp_examples'</span> date_str <span class=quotes>'.txt'</span>];<br>model_file = [<span class=quotes>'tmp_model'</span> date_str <span class=quotes>'.txt'</span>];<br>verb_file = [<span class=quotes>'tmp_verb'</span> date_str <span class=quotes>'.txt'</span>];<br>alpha_file = [<span class=quotes>'tmp_alpha'</span> date_str <span class=quotes>'.txt'</span>];<br><br><span class=comment>% make model</span><br>model.name = <span class=quotes>'SVM classifier'</span>;<br><br><span class=comment>% -- Process input arguments --------------------------</span><br><span class=keyword>if</span> <span class=stack>nargin</span> < 2, options = []; <span class=keyword>else</span> options=c2s(options); <span class=keyword>end</span><br><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'ker'</span>), options.ker = <span class=quotes>'linear'</span>; <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'arg'</span>), options.arg = <span class=quotes>'[]'</span>; <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'C'</span>), options.C = inf; <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'eps'</span>), options.eps = 0.001; <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'keep_files'</span>), options.keep_files = 0; <span class=keyword>end</span><br><span class=keyword>if</span> ~isfield(options,<span class=quotes>'j'</span>), options.j = 1; <span class=keyword>end</span><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -