?? faq.html
字號:
<hr/>
<a name="/Q5:_Probability_outputs"></a>
<a name="f426"><b>Q: Why using the -b option does not give me better accuracy?</b></a>
<br/>
<p>
There is absolutely no reason the probability outputs guarantee
you better accuracy. The main purpose of this option is
to provide you the probability estimates, but not to boost
prediction accuracy. From our experience,
after proper parameter selections, in general with
and without -b have similar accuracy. Occasionally there
are some differences.
It is not recommended to compare the two under
just a fixed parameter
set as more differences will be observed.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q5:_Probability_outputs"></a>
<a name="f427"><b>Q: Why using svm-predict -b 0 and -b 1 gives different accuracy values?</b></a>
<br/>
<p>
Let's just consider two-class classification here. After probability information is obtained in training,
we do not have
<p>
prob > = 0.5 if and only if decision value >= 0.
<p>
So predictions may be different with -b 0 and 1.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q6:_Graphic_interface"></a>
<a name="f501"><b>Q: How can I save images drawn by svm-toy?</b></a>
<br/>
<p>
For Microsoft windows, first press the "print screen" key on the keyboard.
Open "Microsoft Paint"
(included in Windows)
and press "ctrl-v." Then you can clip
the part of picture which you want.
For X windows, you can
use the program "xv" or "import" to grab the picture of the svm-toy window.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q6:_Graphic_interface"></a>
<a name="f502"><b>Q: I press the "load" button to load data points but why svm-toy does not draw them ?</b></a>
<br/>
<p>
The program svm-toy assumes both attributes (i.e. x-axis and y-axis
values) are in (0,1). Hence you want to scale your
data to between a small positive number and
a number less than but very close to 1.
Moreover, class labels must be 1, 2, or 3
(not 1.0, 2.0 or anything else).
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q6:_Graphic_interface"></a>
<a name="f503"><b>Q: I would like svm-toy to handle more than three classes of data, what should I do ?</b></a>
<br/>
<p>
Taking windows/svm-toy.cpp as an example, you need to
modify it and the difference
from the original file is as the following: (for five classes of
data)
<pre>
30,32c30
< RGB(200,0,200),
< RGB(0,160,0),
< RGB(160,0,0)
---
> RGB(200,0,200)
39c37
< HBRUSH brush1, brush2, brush3, brush4, brush5;
---
> HBRUSH brush1, brush2, brush3;
113,114d110
< brush4 = CreateSolidBrush(colors[7]);
< brush5 = CreateSolidBrush(colors[8]);
155,157c151
< else if(v==3) return brush3;
< else if(v==4) return brush4;
< else return brush5;
---
> else return brush3;
325d318
< int colornum = 5;
327c320
< svm_node *x_space = new svm_node[colornum * prob.l];
---
> svm_node *x_space = new svm_node[3 * prob.l];
333,338c326,331
< x_space[colornum * i].index = 1;
< x_space[colornum * i].value = q->x;
< x_space[colornum * i + 1].index = 2;
< x_space[colornum * i + 1].value = q->y;
< x_space[colornum * i + 2].index = -1;
< prob.x[i] = &x_space[colornum * i];
---
> x_space[3 * i].index = 1;
> x_space[3 * i].value = q->x;
> x_space[3 * i + 1].index = 2;
> x_space[3 * i + 1].value = q->y;
> x_space[3 * i + 2].index = -1;
> prob.x[i] = &x_space[3 * i];
397c390
< if(current_value > 5) current_value = 1;
---
> if(current_value > 3) current_value = 1;
</pre>
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q7:_Java_version_of_libsvm"></a>
<a name="f601"><b>Q: What is the difference between Java version and C++ version of libsvm?</b></a>
<br/>
<p>
They are the same thing. We just rewrote the C++ code
in Java.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q7:_Java_version_of_libsvm"></a>
<a name="f602"><b>Q: Is the Java version significantly slower than the C++ version?</b></a>
<br/>
<p>
This depends on the VM you used. We have seen good
VM which leads the Java version to be quite competitive with
the C++ code. (though still slower)
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q7:_Java_version_of_libsvm"></a>
<a name="f603"><b>Q: While training I get the following error message: java.lang.OutOfMemoryError. What is wrong?</b></a>
<br/>
<p>
You should try to increase the maximum Java heap size.
For example,
<pre>
java -Xmx2048m -classpath libsvm.jar svm_train ...
</pre>
sets the maximum heap size to 2048M.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q7:_Java_version_of_libsvm"></a>
<a name="f604"><b>Q: Why you have the main source file svm.m4 and then transform it to svm.java?</b></a>
<br/>
<p>
Unlike C, Java does not have a preprocessor built-in.
However, we need some macros (see first 3 lines of svm.m4).
</ul>
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q8:_Python_interface"></a>
<a name="f702"><b>Q: On MS windows, why does python fail to load the pyd file?</b></a>
<br/>
<p>
It seems the pyd file is version dependent. So far we haven't
found out a good solution. Please email us if you have any
good suggestions.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q8:_Python_interface"></a>
<a name="f703"><b>Q: How to modify the python interface on MS windows and rebuild the .pyd file ?</b></a>
<br/>
<p>
To modify the interface, follow the instructions given in
<a href=
http://www.swig.org/Doc1.3/Python.html#Python>
http://www.swig.org/Doc1.3/Python.html#Python
</a>
<p>
If you just want to build .pyd for a different python version,
after libsvm 2.5, you can easily use the file Makefile.win.
See details in README.
Alternatively, you can use Visual C++. Here is
the example using Visual Studio .Net 2005:
<ol>
<li>Create a Win32 DLL project and set (in Project->$Project_Name
Properties...->Configuration) to "Release."
About how to create a new dynamic link library, please refer to
<a href=http://msdn2.microsoft.com/en-us/library/ms235636(VS.80).aspx>http://msdn2.microsoft.com/en-us/library/ms235636(VS.80).aspx</a>
<li> Add svm.cpp, svmc_wrap.c, pythonXX.lib to your project.
<li> Add the directories containing Python.h and svm.h to the Additional
Include Directories(in Project->$Project_Name
Properties...->C/C++->General)
<li> Add __WIN32__ to Preprocessor definitions (in
Project->$Project_Name Properties...->C/C++->Preprocessor)
<li> Set Create/Use Precompiled Header to Not Using Precompiled Headers
(in Project->$Project_Name Properties...->C/C++->Precompiled Headers)
<li> Build the DLL.
<li> You may have to rename .dll to .pyd
</ol>
<!--
There do exist work arounds, however. In
http://aspn.activestate.com/ASPN/Mail/Message/python-list/983252
they presented a solution: 1) find the version of python in the
registry 2) perform LoadLibrary("pythonxx.dll") and 3) resolve the
reference to functions through GetProcAddress. It is said that SWIG
may help on this.
http://mailman.cs.uchicago.edu/pipermail/swig/2001-July/002744.html
presented a similar example.
-->
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q8:_Python_interface"></a>
<a name="f704"><b>Q: Except the python-C++ interface provided, could I use Jython to call libsvm ?</b></a>
<br/>
<p> Yes, here are some examples:
<pre>
$ export CLASSPATH=$CLASSPATH:~/libsvm-2.4/java/libsvm.jar
$ ./jython
Jython 2.1a3 on java1.3.0 (JIT: jitc)
Type "copyright", "credits" or "license" for more information.
>>> from libsvm import *
>>> dir()
['__doc__', '__name__', 'svm', 'svm_model', 'svm_node', 'svm_parameter',
'svm_problem']
>>> x1 = [svm_node(index=1,value=1)]
>>> x2 = [svm_node(index=1,value=-1)]
>>> param = svm_parameter(svm_type=0,kernel_type=2,gamma=1,cache_size=40,eps=0.001,C=1,nr_weight=0,shrinking=1)
>>> prob = svm_problem(l=2,y=[1,-1],x=[x1,x2])
>>> model = svm.svm_train(prob,param)
*
optimization finished, #iter = 1
nu = 1.0
obj = -1.018315639346838, rho = 0.0
nSV = 2, nBSV = 2
Total nSV = 2
>>> svm.svm_predict(model,x1)
1.0
>>> svm.svm_predict(model,x2)
-1.0
>>> svm.svm_save_model("test.model",model)
</pre>
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q8:_Python_interface"></a>
<a name="f705"><b>Q: How could I install the python interface on Mac OS? </b></a>
<br/>
<p> Instead of
LDFLAGS = -shared
in the Makefile, you need
<pre>
LDFLAGS = -framework Python -bundle
</pre>
<!--
LDFLAGS = -bundle -flat_namespace -undefined suppress
-->
The problem is that under MacOs there is no "shared libraries."
Instead they use "dynamic libraries."
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q8:_Python_interface"></a>
<a name="f706"><b>Q: I typed "make" on a unix system, but it says "Python.h: No such file or directory?"</b></a>
<br/>
<p>
Even though you may have python on your
system, very likely
python development tools
are not installed. Please check with
your system administrator.
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q9:_MATLAB_interface"></a>
<a name="f801"><b>Q: I compile the MATLAB interface without problem, but why errors occur while running it?</b></a>
<br/>
<p>
Your compiler version may not be supported/compatible for MATLAB.
Please check <a href=http://www.mathworks.com/support/tech-notes/1600/1601.html>this MATLAB page</a> first and then specify the version
number. For example, if g++ 3.3 is supported, replace
<pre>
CXX = g++
</pre>
in the Makefile with
<pre>
CXX = g++-3.3
</pre>
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<a name="/Q9:_MATLAB_interface"></a>
<a name="f802"><b>Q: Does the MATLAB interface provide a function to do scaling?</b></a>
<br/>
<p>
It is extremely easy to do scaling under MATLAB.
The following one-line code scale each feature to the range
of [0.1]:
<pre>
(data - repmat(min(data,[],1),size(data,1),1))./(repmat(max(data,[],1)-min(data,[],1),size(data,1),1))
</pre>
<p align="right">
<a href="#_TOP">[Go Top]</a>
<hr/>
<p align="middle">
<a href="http://www.csie.ntu.edu.tw/~cjlin/libsvm">LIBSVM home page</a>
</p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -