view toolboxes/SVM-light/svm_light_faq.html @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line source
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft FrontPage 6.0">
<TITLE>svm_light_faq</TITLE>
<META NAME="Version" CONTENT="8.0.3514">
<META NAME="Date" CONTENT="11/26/96">
<META NAME="Template" CONTENT="C:\Programme\Microsoft Office\Office\HTML.DOT">
</HEAD>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">

<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=5>
<TR><TD WIDTH="14%" VALIGN="TOP">
<H2><a TARGET="_top" HREF="http://www-ai.cs.uni-dortmund.de/"><IMG SRC="eier_graybg.gif" BORDER=0 WIDTH=100 HEIGHT=81></A></H2></TD>
<TD WIDTH="75%" VALIGN="TOP">
<H1 ALIGN="CENTER">SVM<I><SUP>light</SUP> &amp;</I> SVM<sup><i>struct</i></sup><I>
</I> </H1>
<H1 ALIGN="CENTER">FAQ</H1>
<FONT COLOR="#000000"><P ALIGN="CENTER">Author: </FONT><a TARGET="_top" HREF="http://www.joachims.org/">Thorsten Joachims</A><FONT COLOR="#000000"> &lt;</FONT><A HREF="mailto:thorsten@joachims.org">thorsten@joachims.org</A><FONT COLOR="#000000">&gt; <BR>
</FONT><a TARGET="_top" HREF="http://www.cornell.edu/">Cornell University</A><FONT COLOR="#000000"> <BR>
</FONT><a TARGET="_top" HREF="http://www.cs.cornell.edu/">Department of Computer Science</A><FONT COLOR="#000000"> </P>
<P ALIGN="CENTER">Developed at: <BR>
</FONT><a TARGET="_top" HREF="http://www.uni-dortmund.de/">University of Dortmund</A><FONT COLOR="#000000">, </FONT><a TARGET="_top" HREF="http://www.informatik.uni-dortmund.de/">Informatik</A><FONT COLOR="#000000">, </FONT><a TARGET="_top" HREF="http://www-ai.informatik.uni-dortmund.de/">AI-Unit</A><FONT COLOR="#000000"> <BR>
</FONT><a TARGET="_top" HREF="http://www.sfb475.uni-dortmund.de/">Collaborative Research Center on 'Complexity Reduction in Multivariate Data' (SFB475)</A><FONT COLOR="#000000"> </FONT> </P>
<P ALIGN="CENTER"><FONT COLOR="#000000"> Date: 25. May, 2009</FONT></P></TD>
<TD WIDTH="11%" VALIGN="TOP">
<H2><IMG SRC="http://www.joachims.org/images/culogo_125.gif" WIDTH=80 HEIGHT=80></H2></TD>
</TR>
</TABLE>

<H2>How do I compile on a Windows PC?</H2>
<UL>
	<LI>The following instructions apply to SVM<I><SUP>light</SUP></I>, SVM<sup><i>struct</i></sup>, SVM<sup><i>perf</i></sup>, SVM<sup><i>cfg</i></sup>, SVM<sup><i>multiclass</i></sup>, 
	and SVM<sup><i>hmm</i></sup>. </LI>
	<LI>The easiest is to install <a href="http://www.cygwin.com">CYGWIN</a> and 
	use the gcc compiler that comes with the Cygwin distribution. Just open a 
	cygwin command window, change to the directory that contains file &quot;Makefile&quot; and type 
	<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; make<br>
	at the command prompt. This creates executables that run under Cygwin.</LI>
	<LI>If you want execuables that do not need Cygwin to run, follow the same 
	instructions as above, but make sure that you download the MinGW package as 
	part of Cygwin. Then use the command <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; make 'SFLAGS=-mno-cygwin'<br>
	to create the executables.</LI>
	<LI>You can also use the Visual C compiler, but it will be much more of a 
	hassle than using Cygwin. To use Visual C, you need to build the appropriate project file according to the provided <TT>"Makefile"</TT>. 
Make sure you do not include the file &quot;svm_loqo.c&quot; in your project, unless you 
want to use the PL_LOQO optimizer instead of the built-in optimizer.</p>
</UL>

<H2>How do I compile on a PowerMac using Code Warrior?</H2>

<UL>
<LI>This applies to SVM<I><SUP>light</SUP></I>, but should also work for SVM<sup><i>struct</i></sup>, SVM<sup><i>perf</i></sup>, SVM<sup><i>cfg</i></sup>, SVM<sup><i>multiclass</i></sup>, 
	and SVM<sup><i>hmm</i></sup>. </LI>
<LI>You need to modify the source code a little (as suggested by Jewgeni Starikow). Use <TT>#include "console.h"</TT> to emulate a UNIX shell. Then add <TT>argc=ccommand(&amp;argv)</TT> as the first instruction of each <TT>main()</TT>. </LI>
<LI>CPU-timing might cause another problem. The timing routines are used to calculated the runtime of the program. If you do not need this feature, remove the body of <TT>get_runtime()</TT> in <TT>svm_common.c</TT>. Otherwise replace the body with the appropriate Mac routines from <TT>'time.h'</TT>. </LI></UL>
<H2>How do I integrate SVM<SUP>light</SUP> into C++ code?</H2>

<UL>
<LI>Compile <TT>"svm_learn.c"</TT>, <TT>"svm_common.c"</TT>, and <TT>"svm_hideo.c"</TT> as C code.</LI>
<LI>The C++ program you want to call <TT>svm_learn/8</TT> and <TT>classify_example/2 </TT>(or <TT>classify_example_linear/2</TT>) from needs to include the following headers:<BR>
<FONT FACE="Courier New" SIZE=2>extern "C" {<BR>
# include "svm_common.h"<BR>
# include "svm_learn.h"<BR>
} </FONT> </LI>
<LI>Link <TT>"svm_learn.o"</TT>, <TT>"svm_common.o"</TT>, and <TT>"svm_hideo.o" </TT>to your program.</LI></UL>

<h2>Is there an option for doing multi-class classification?</h2>
<ul>
  <li>Not in SVM<I><SUP>light</SUP></I>. If you do not use kernel, you can 
		use <a href="svm_multiclass.html">SVM<sup><i>multiclass</i></sup></a> to 
		do multi-class classification. Otherwise, I recommend to split the task 
		into multiple binary classification tasks for multi-class or multi-label classification. For
        example, you can do one-class-against-the-rest classification, or pairwise classification. Refer to Chapter 2 in [<a href="index.html#References">Joachims,
        2002a</a>].</li>
</ul>

<h2>Is there an option for doing cross-validation?</h2>
<ul>
  <li>Yes, there is such an option in SVM<I><SUP>light</SUP></I>, but not in SVM<sup><i>struct</i></sup>. 
  By setting the option &quot;-x 1&quot;, SVM<I><SUP>light</SUP></I> computes the 
  leave-one-out estimates of the prediction error, recall, precision, and F1. By 
  default, it also outputs the XiAlpha-Estimates of these quantities. They are 
  strictly conservative approximations to the leave-one-out (i.e. they never 
  underestimate the leave-one-out error). Refer to Chapter 5 in [<a href="index.html#References">Joachims,
        2002a</a>].</li>
</ul>
<h2>How can I output the dual variables at the solution?</h2>
<ul>
  <li>Use the option -a &lt;filename&gt;. The file contains the value of the 
  dual variables (multiplied by the label y) for each training example in the 
  order in which the examples appeared in the training file.</li>
</ul>
<h2>How can I get the weight vector of the hyperplane for a linear SVM?</h2>
<ul>
  <li>There is a small <a href="svm2weight.pl.txt">PERL script to 
      compute the weight vector</a> (<a href="svm2weight.py.txt">similar script in 
	PYTHON by Ori Cohen</a>) based on the model file output by svm_learn 
		and svm_perf_learn. 
      Of course, it works only in the linear case and not for kernels. All the 
      script does is compute the weighted sum of the support vectors (first
        element in line is alpha*y, what follows is the feature vector). For 
      further info, see the comment in the model file for its format.
  </li>
</ul>

<h2>What is the format of the learned model file?</h2>
<ul>
  <li>The model files produced by svm_learn and svm_perf_learn are in ASCII and 
  easy to read. The first few lines contain parameters. The comments in the 
  model file are self-explanatory. The last of these is the threshold b of the 
  learned hyperplane classifier sign(w*x - b). The following lines each contain 
  a support vector, and the first element of the line is its coefficient (alpha_i 
  * y_i) in the kernel expansion. The support vectors are listed in random 
  order. Note that the term support vector has a different meaning in SVM<sup>perf</sup> 
  compared to SVM<SUP>light</SUP>.</li>
</ul>


<h2>How can I implement my own Kernel?</h2>
<ul>
  <li>You can write your own kernel by extending the function &quot;double 
  custom_kernel(KERNEL_PARM *kernel_parm, SVECTOR *a, SVECTOR *b)&quot; in &quot;kernel.h&quot; 
  and then select it via the &quot;-t 4&quot; option. The &quot;a&quot; and &quot;b&quot; are pointers to the 
  examples you are computing the kernel for.</li>
  <ul>
    <li>If the data you are working with is vectorial, then you can use the 
    existing sparse vector operations defined in svm_common.c. For example,<br>
&nbsp;&nbsp;&nbsp; pow(sprod_ss(a-&gt;words,b-&gt;words),2.0) <br>
    implements the homogeneous polynomial kernel of degree 2.</li>
    <li>If the data is non-vectorial (e.g. strings), then you can use the 
    following functionality. In the training and test data files, whatever is 
    written behind the &quot;#&quot; is copied into the &quot;userdefined&quot; field of the 
    internal datastructure &quot;SVECTOR&quot; as a string. So, for the line<br>
&nbsp;&nbsp;&nbsp; +1 #abcdefg<br>
    you will find &quot;abcdefg&quot; in &quot;svector-&gt;userdefined&quot;.</li>
  </ul>
</ul>


<H2>Error messages and known problems:</H2>

<UL>
<TT><LI>ERROR: terminating optimizer - choldc failed, matrix not positive definite</TT> </LI>

<UL>
<LI>If the program terminates after this message, get the lastest version of PR_LOQO and SVM-Light V2.01 (or later). </LI>
<LI>It the program continues after this error message, don't worry :-) </LI></UL>

<I><LI>The CPU-time is negative or looks bogus:</I> </LI>

<UL>
<LI>To be compatible with Windows, I used the <TT>clock/0</TT> function to measure CPU-time. This function returns a long integer and counts microseconds, so that it wraps around after about 30 minutes. You could use timing routines more appropriate for your system. For example on Solaris, you might want to use the routines from <TT>'sys/times.h'</TT>.</LI></UL>
</UL>

<H2>The program hangs when ...</H2>

<UL>
<I><LI>... reading in the examples.</I> </LI>

<UL>
<LI>Get version 3.02 or later. </LI></UL>
</UL>

<H2>Convergence during learning is very slow!</H2>

<UL>
<I><LI>In verbose mode 2 I observe that <TT>max violation</TT> bounces around and does not really converge.</I> </LI>

<UL>
<LI>Use a smaller value for the option -n (default n=q). This makes sure that only n new variables enter the working set in each iteration. This can prevent zig-zagging behavior.</LI>
<LI>Use a smaller or larger value for the size of the working set (option -q). Reasonable values are in the range [2:50].</LI>
<LI>You might be using an excessively large value of C (option -c) in relation to your data. The value of C should typically be less than 1000 times 1.0/(the maximum squared Euclidian length of your feature vectors). </LI>
<LI>You have weired data and the convergence simply IS very slow <FONT FACE="Wingdings">&#74;</FONT>
. Sorry, not much you can do about it. </LI></UL>

<I><LI>Nearly all my training examples end up as support vectors.</I> </LI>

<UL>
<LI>Use a "stiffer" kernel (e g. a lower value of gamma for the RBF-kernel). If you pick a kernel which is very far away from the optimum, you will not get good generalization performance anyway. </LI>
<LI>Your data is really difficult to separate. Think about a better representation of your data. It is a bad idea - for example - if different features have values in very much different orders of magnitude. You might want to normalize all features to the range [-1,+1]. </LI></UL>
</UL>

<H2>It does not converge!</H2>

<UL>
<LI>If you are using the built-in HIDEO optimizer, get the version 3.50 or later. There used to be problems for low dimensional data sets for the old HIDEO optimizer.</LI>
<LI>It should always converge, unless there are numerical problems :-) </LI>
<LI>Numerical problems. </LI>

<UL>
<LI>Make sure your data is properly scaled. It is a bad idea - for example - if different features have values in different orders of magnitude. You might want to normalize all features to the range [-1,+1], especially for problems with more than 100 features. Or even better, normalize all feature vectors to Euclidian length 1.</LI></UL>
</UL>

<h2>It crashes!</h2>
<ul>
  <li><i>It crashes during learning when using a non-linear kernel.</i>
    <ul>
      <li>Get version 5.00 or later. There was an initialization bug in the
        kernel cache.</li>
    </ul>
  </li>
</ul>
<h2>The results look bogus!</h2>
<ul>
  <li><i>When doing transductive learning, for some training set sizes it does
    not obey the -p parameter and the results look bogus.</i>
    <ul>
      <li>Get version 5.00 or later. There was a bug introduced in version 4.00.</li>
    </ul>
  </li>
</ul>

<FONT COLOR="#000000">
<P>Last modified July 1st, 2007 by </FONT><a TARGET="_top" HREF="http://www.joachims.org">Thorsten Joachims</A><FONT COLOR="#000000"> &lt;</FONT><a HREF="mailto:thorsten@joachims.org">thorsten@joachims.org</a><FONT COLOR="#000000">&gt;</P></FONT></BODY>
</HTML>