source: orange/docs/reference/rst/Orange.classification.svm.rst @ 10369:3d067903408f

Revision 10369:3d067903408f, 4.4 KB checked in by janezd <janez.demsar@…>, 2 years ago (diff)

Polished documentation about SVM

Line 
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.
68   
69.. autoclass:: Orange.classification.svm.LinearSVMLearner
70   :members:
71   
72.. autoclass:: Orange.classification.svm.MultiClassSVMLearner
73   :members:
74   
75   
76SVM Based feature selection and scoring
77=======================================
78
79.. autoclass:: Orange.classification.svm.RFE
80
81.. autoclass:: Orange.classification.svm.ScoreSVMWeights
82    :show-inheritance:
83 
84 
85Utility functions
86=================
87
88.. automethod:: Orange.classification.svm.max_nu
89
90.. automethod:: Orange.classification.svm.get_linear_svm_weights
91
92.. automethod:: Orange.classification.svm.table_to_svm_format
93
94The following example shows how to get linear SVM weights:
95   
96.. literalinclude:: code/svm-linear-weights.py   
97
98
99.. _kernel-wrapper:
100
101Kernel wrappers
102===============
103
104Kernel wrappers are helper classes for building custom kernels for use
105with :class:`SVMLearner` and subclasses. They take and transform one
106or two Python functions (attributes :obj:`wrapped` or :obj:`wrapped1`
107and :obj:`wrapped2`). The function must be a positive definite kernel
108that takes two arguments of type :class:`Orange.data.Instance` and
109returns a float.
110
111.. autoclass:: Orange.classification.svm.kernels.KernelWrapper
112   :members:
113
114.. autoclass:: Orange.classification.svm.kernels.DualKernelWrapper
115   :members:
116
117.. autoclass:: Orange.classification.svm.kernels.RBFKernelWrapper
118   :members:
119
120.. autoclass:: Orange.classification.svm.kernels.PolyKernelWrapper
121   :members:
122
123.. autoclass:: Orange.classification.svm.kernels.AdditionKernelWrapper
124   :members:
125
126.. autoclass:: Orange.classification.svm.kernels.MultiplicationKernelWrapper
127   :members:
128
129.. autoclass:: Orange.classification.svm.kernels.CompositeKernelWrapper
130   :members:
131
132.. autoclass:: Orange.classification.svm.kernels.SparseLinKernel
133   :members:
134
135Example:
136
137.. literalinclude:: code/svm-custom-kernel.py
138
139.. _`Support Vector Machine`: http://en.wikipedia.org/wiki/Support_vector_machine
140.. _`LibSVM`: http://www.csie.ntu.edu.tw/~cjlin/libsvm/
141.. _`LIBLINEAR`: http://www.csie.ntu.edu.tw/~cjlin/liblinear/
Note: See TracBrowser for help on using the repository browser.