This file is indexed.

/usr/share/pyshared/mvpa/clfs/svm.py is in python-mvpa 0.4.8-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
#   See COPYING file distributed along with the PyMVPA package for the
#   copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Importer for the available SVM and SVR machines.

Multiple external libraries implementing Support Vector Machines
(Classification) and Regressions are available: LIBSVM, and shogun.
This module is just a helper to provide default implementation for SVM
depending on the availability of external libraries. By default LIBSVM
implementation is choosen by default, but in any case both libraries
are available through importing from this module:

> from mvpa.clfs.svm import sg, libsvm
> help(sg.SVM)
> help(libsvm.SVM)

Please refer to particular interface for more documentation about
parametrization and available kernels and implementations.
"""

__docformat__ = 'restructuredtext'

# take care of conditional import of external classifiers
from mvpa.base import warning, cfg, externals
from _svmbase import _SVM

if __debug__:
    from mvpa.base import debug

# default SVM implementation
SVM = None
_NuSVM = None


# TODO: handle choices within cfg
_VALID_BACKENDS = ('libsvm', 'shogun', 'sg')
default_backend = cfg.get('svm', 'backend', default='libsvm').lower()
if default_backend == 'shogun':
    default_backend = 'sg'

if not default_backend in _VALID_BACKENDS:
    raise ValueError, 'Configuration option svm.backend got invalid value %s.' \
          ' Valid choices are %s' % (default_backend, _VALID_BACKENDS)

if __debug__:
    debug('SVM', 'Default SVM backend is %s' % default_backend)

if externals.exists('shogun'):
    from mvpa.clfs import sg
    SVM = sg.SVM
    #if not 'LinearCSVMC' in locals():
    #    from mvpa.clfs.sg.svm import *

if externals.exists('libsvm'):
    # By default for now we want simply to import all SVMs from libsvm
    from mvpa.clfs import libsvmc as libsvm
    _NuSVM = libsvm.SVM
    if default_backend == 'libsvm' or SVM is None:
        if __debug__ and default_backend != 'libsvm' and SVM is None:
            debug('SVM',
                  'Default SVM backend %s was not found, so using libsvm'
                  % default_backend)
        SVM = libsvm.SVM
    #from mvpa.clfs.libsvm.svm import *

if SVM is None:
    warning("None of SVM implementions libraries was found")
else:
    _defaultC = _SVM._SVM_PARAMS['C'].default
    _defaultNu = _SVM._SVM_PARAMS['nu'].default

    # Define some convinience classes
    class LinearCSVMC(SVM):
        """C-SVM classifier using linear kernel.

        See help for %s for more details
        """ % SVM.__class__.__name__

        def __init__(self, C=_defaultC, **kwargs):
            """
            """
            # init base class
            SVM.__init__(self, C=C, kernel_type='linear', **kwargs)


    class RbfCSVMC(SVM):
        """C-SVM classifier using a radial basis function kernel.

        See help for %s for more details
        """ % SVM.__class__.__name__

        def __init__(self, C=_defaultC, **kwargs):
            """
            """
            # init base class
            SVM.__init__(self, C=C, kernel_type='RBF', **kwargs)

    if _NuSVM is not None:
        class LinearNuSVMC(_NuSVM):
            """Nu-SVM classifier using linear kernel.

            See help for %s for more details
            """ % _NuSVM.__class__.__name__

            def __init__(self, nu=_defaultNu, **kwargs):
                """
                """
                # init base class
                _NuSVM.__init__(self, nu=nu, kernel_type='linear', **kwargs)

        class RbfNuSVMC(SVM):
            """Nu-SVM classifier using a radial basis function kernel.

            See help for %s for more details
            """ % SVM.__class__.__name__

            def __init__(self, nu=_defaultNu, **kwargs):
                # init base class
                SVM.__init__(self, nu=nu, kernel_type='RBF', **kwargs)