source: orange/docs/reference/rst/Orange.classification.svm.rst @ 11605:a35955141513

Revision 11605:a35955141513, 5.0 KB checked in by Ales Erjavec <ales.erjavec@…>, 10 months ago (diff)

Added some basic documentation for the LIBLINEAR based classifiers.

RevLine 
[10369]1.. py:currentmodule:: Orange.classification.svm
2
3.. index:: support vector machines (SVM)
4.. index:
5   single: classification; support vector machines (SVM)
6   
7*********************************
8Support Vector Machines (``svm``)
9*********************************
10
11The module for `Support Vector Machine`_ (SVM) classification is based
12on the popular `LibSVM`_ and `LIBLINEAR`_ libraries. It provides several
13learning algorithms:
14
15- :obj:`SVMLearner`, a general SVM learner;
16- :obj:`SVMLearnerEasy`, which is similar to the `svm-easy.py` script
17    from the LibSVM distribution and helps with the data normalization and
18    parameter tuning;
19- :obj:`LinearSVMLearner`, a fast learner useful for data sets with a large
20    number of features.
21         
22SVM learners (from `LibSVM`_)
23=============================
24
25:class:`SVMLearner` uses the standard `LibSVM`_ learner. It supports
26several built-in kernel types and user-defined kernels functions
27written in Python. The kernel type is denoted by constants ``Linear``,
28``Polynomial``, ``RBF``, ``Sigmoid`` and ``Custom`` defined in
29``Orange.classification.svm.kernels``.  A custom kernel function must
30accept two data instances and return a float. See
31:ref:`kernel-wrapper` for examples.
32   
33The class also supports several types of optimization: ``C_SVC``,
34``Nu_SVC`` (default), ``OneClass``, ``Epsilon_SVR`` and ``Nu_SVR``
35(defined in ``Orange.classification.svm.SVMLearner``).
36
37Class :obj:`SVMLearner` works on non-sparse data and
38:class:`SVMLearnerSparse` class works on sparse data sets, for
39instance data from the `basket` format).
40
41.. autoclass:: Orange.classification.svm.SVMLearner
42    :members:
43
44.. autoclass:: Orange.classification.svm.SVMLearnerSparse
45    :members:
46    :show-inheritance:
47   
48.. autoclass:: Orange.classification.svm.SVMLearnerEasy
49    :members:
50    :show-inheritance:
51
52The example below compares the performances of :obj:`SVMLearnerEasy`
53with automatic data preprocessing and parameter tuning and
54:obj:`SVMLearner` with the default :obj:`~SVMLearner.nu` and
55:obj:`~SVMLearner.gamma`:
56   
57.. literalinclude:: code/svm-easy.py
58
59
60   
61Linear SVM learners (from `LIBLINEAR`_)
62=======================================
63
64Linear SVM learners are more suitable for large scale problems since
65they are significantly faster then :class:`SVMLearner` and its
66subclasses. A down side is that they support only a linear kernel and
67can not estimate probabilities.
[11605]68
[10369]69   
70.. autoclass:: Orange.classification.svm.LinearSVMLearner
71   :members:
[11605]72
[10369]73   
74.. autoclass:: Orange.classification.svm.MultiClassSVMLearner
75   :members:
[11605]76
77
78.. class:: LinearClassifier
79
80   The classifier returned by LIBLINEAR based learners.
81
82   .. attribute:: weights
83
84      A 2 dim table of computed feature weights of the classifier,
85      one for each one vs. rest underlying binary classifier (i.e.
86      ``classifier.weights[i]`` contains the i'th class vs. rest
87      binary classifier weights. If :attr:`bias` > 0 then the bias
88      weight term is appended as the last element of the weight
89      vector.
90
91   .. attribute:: bias
92
93      The bias parameter as passed to the learner.
[10369]94   
95   
96SVM Based feature selection and scoring
97=======================================
98
99.. autoclass:: Orange.classification.svm.RFE
[10696]100   :members: __init__, __call__
[10369]101
102.. autoclass:: Orange.classification.svm.ScoreSVMWeights
[10696]103   :members: __init__, __call__
104   :show-inheritance:
[10369]105 
106 
107Utility functions
108=================
109
110.. automethod:: Orange.classification.svm.max_nu
111
112.. automethod:: Orange.classification.svm.get_linear_svm_weights
113
114.. automethod:: Orange.classification.svm.table_to_svm_format
115
116The following example shows how to get linear SVM weights:
117   
118.. literalinclude:: code/svm-linear-weights.py   
119
120
121.. _kernel-wrapper:
122
123Kernel wrappers
124===============
125
126Kernel wrappers are helper classes for building custom kernels for use
127with :class:`SVMLearner` and subclasses. They take and transform one
128or two Python functions (attributes :obj:`wrapped` or :obj:`wrapped1`
129and :obj:`wrapped2`). The function must be a positive definite kernel
130that takes two arguments of type :class:`Orange.data.Instance` and
131returns a float.
132
133.. autoclass:: Orange.classification.svm.kernels.KernelWrapper
134   :members:
135
136.. autoclass:: Orange.classification.svm.kernels.DualKernelWrapper
137   :members:
138
139.. autoclass:: Orange.classification.svm.kernels.RBFKernelWrapper
140   :members:
141
142.. autoclass:: Orange.classification.svm.kernels.PolyKernelWrapper
143   :members:
144
145.. autoclass:: Orange.classification.svm.kernels.AdditionKernelWrapper
146   :members:
147
148.. autoclass:: Orange.classification.svm.kernels.MultiplicationKernelWrapper
149   :members:
150
151.. autoclass:: Orange.classification.svm.kernels.CompositeKernelWrapper
152   :members:
153
154.. autoclass:: Orange.classification.svm.kernels.SparseLinKernel
155   :members:
156
157Example:
158
159.. literalinclude:: code/svm-custom-kernel.py
160
161.. _`Support Vector Machine`: http://en.wikipedia.org/wiki/Support_vector_machine
162.. _`LibSVM`: http://www.csie.ntu.edu.tw/~cjlin/libsvm/
163.. _`LIBLINEAR`: http://www.csie.ntu.edu.tw/~cjlin/liblinear/
Note: See TracBrowser for help on using the repository browser.