⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faq.html

📁 我一直覺得 SVM 是個很有趣的東西
💻 HTML
📖 第 1 页 / 共 4 页
字号:
So far we have not found a good solution. 
Please try to close gnuplot windows and rerun.
If the problem still occurs, comment the following
two lines in grid.py by inserting "#" in the beginning:
<pre>
        redraw(db)
        redraw(db,1)
</pre>
Then you get accuracy only but not cross validation contours.
<p align="right">
<a href="#_TOP">[Go Top]</a>  
<hr/>
  <a name="/Q4:_Training_and_prediction"></a>
<a name="f429"><b>Q: Why grid.py/easy.py sometimes generates the following warning message?</b></a>
<br/>                                                                                
<pre>
Warning: empty z range [62.5:62.5], adjusting to [61.875:63.125]
Notice: cannot contour non grid data!
</pre>
<p>Nothing is wrong and please disregard the 
message. It is from gnuplot when drawing
the contour.  
<p align="right">
<a href="#_TOP">[Go Top]</a>  
<hr/>
  <a name="/Q4:_Training_and_prediction"></a>
<a name="f430"><b>Q: Is there a way to speed up the pow() function used in calculating polynomial kernels?</b></a>
<br/>                                                                                
<p>
The pow() function of some libraries (e.g., glibc) is 
inefficient when the degree is a small positive integer.
You can add in svm.cpp the following simple mypow() function:
<pre>
inline double mypow(double base, int times){
        double tmp = base, ret = 1.0;

        for(int t=times; t>0; t/=2){
                if(t%2==1) ret*=tmp;
                tmp = tmp * tmp;
        }
        return ret;
}
</pre>
and replace the two places of pow() with mypow().
<p align="right">
<a href="#_TOP">[Go Top]</a>  
<hr/>
  <a name="/Q5:_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" to grab the picture of the svm-toy window.
<p align="right">
<a href="#_TOP">[Go Top]</a>  
<hr/>
  <a name="/Q5:_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="/Q5:_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="/Q6:_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="/Q6:_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="/Q6:_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 -Xmx256m svm_train.java ...
</pre>
sets the maximum heap size to 256M.
<p align="right">
<a href="#_TOP">[Go Top]</a>  
<hr/>
  <a name="/Q6:_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="/Q7:_Python_Interface"></a>
<a name="f702"><b>Q: On MS windows, why does python fail to load the dll file?</b></a>
<br/>                                                                                
<p>
It seems the dll 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="/Q7:_Python_Interface"></a>
<a name="f703"><b>Q: How to modify the python interface on MS windows and rebuild the dll file ?</b></a>
<br/>                                                                                
<p>

To modify the interface, follow the instructions given in
<a href=http://www.swig.org/Doc1.1/HTML/Python.html#n2>
http://www.swig.org/Doc1.1/HTML/Python.html#n2</a>

<p>

If you just want to build DLL 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++:
<ol>
<li> Create a Win32 DLL project and set (Build->Active Configuration) to "Release."
<li> Add svm.cpp, svmc_wrap.c, python2x.lib to your project.
<li> Add the directories containing Python.h and svm.h to
the Additional include directories. (in Project
Settings->C/C++->Preprocessor)
<li> add __WIN32__ to Preprocessor definitions
<li> Make sure that in the "General" category of
Project->Settings->Settings For "Win32 Release", Output
directories should be "Release"
<li> Build the DLL.
</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="/Q7:_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="/Q7:_Python_Interface"></a>
<a name="f705"><b>Q: How could I install the python interface on Mac OS? </b></a>
<br/>                                                                                
<p> According to S V N Vishwanathan at Australian National University, instead of 
LDFLAGS = -shared
in the Makefile, you need
<pre>
LDFLAGS = -bundle -flat_namespace -undefined suppress
</pre>
<p align="right">
<a href="#_TOP">[Go Top]</a>  
<hr/>
  <a name="/Q8:_MATLAB_Interface"></a>
<a name="f801"><b>Q: I compile the MATLAB interface without problem, but why errors</b></a>
<br/>                                                                                
occue while running it?
<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/>
  <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 + -