## Selecting SVM kernel types

7 posts
• Page

**1**of**1**### Selecting SVM kernel types

I am experimenting with SVMs in Orange, but it is a bit unclear to me how to select different kernel types.

The documentation refers to 5 possible kernel types:

But, if I try to use any of these, I get an error:

When digging in the code in source/ornsSVM.py I see the kernel types are defined as ints, and infer that 2 means "RBF" and 4 means "custom kernel". There do not seem to be definitions for the names (e.g. "Linear" = 0, "RBF" = 2) in the code. What am I missing?

The documentation refers to 5 possible kernel types:

(quoted from: http://www.ailab.si/orange/doc/reference/SupportVectorMachines.htm)

kernel_type

Defines the type of a kernel to use for learning (can be SVMLearner.RBF (default), SVMLearner.Linear, SVMLearner.Polynomial, SVMLearner.Sigmoid, SVMLearner.Custom)

But, if I try to use any of these, I get an error:

- Code: Select all
`>>> svm = orngSVM.SVMLearner(kernel_type=orngSVM.SVMLearner.Linear, C = 2048, normalization=True, name="SVM")`

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

AttributeError: type object 'SVMLearner' has no attribute 'Linear'

When digging in the code in source/ornsSVM.py I see the kernel types are defined as ints, and infer that 2 means "RBF" and 4 means "custom kernel". There do not seem to be definitions for the names (e.g. "Linear" = 0, "RBF" = 2) in the code. What am I missing?

### Figured it out

I solved the problem, the definitions were in orange.SVMLearner (thanks to Python help()). However, these names are still ALL_CAPS so still not the same as in the documentation.

To select a linear kernel:

However, I noted a different problem. In the documentation it is stated that C_SVC is the default SVM-type, but this does not seem to be true:

The help shows that svm_type 1 corresponds with NU_SVC, instead of the desired C_SVC. So, if you want a C_SVC svm you MUST specify that!

To select a linear kernel:

- Code: Select all
`svm = orngSVM.SVMLearner( kernel_type=orange.SVMLearner.LINEAR, C = 2 ** 10, normalization=True, name="svm" )`

However, I noted a different problem. In the documentation it is stated that C_SVC is the default SVM-type, but this does not seem to be true:

- Code: Select all
`>>> svm = orngSVM.SVMLearner( kernel_type=orange.SVMLearner.LINEAR, C = 2 ** 10, normalization=True, name="svm" )`

>>> print svm.svm_type

1

>>> help(svm)

The help shows that svm_type 1 corresponds with NU_SVC, instead of the desired C_SVC. So, if you want a C_SVC svm you MUST specify that!

Are you sure you have sources checked out from www.ailab.si/svn/orange/branches/ver1.0/source/ and not from the trunk?

- Code: Select all
`Path: .`

URL: http://www.ailab.si/svn/orange/branches/ver1.0/source

Repository Root: http://www.ailab.si/svn/orange

Repository UUID: abb54cfb-9aa5-4a4f-ad95-02929a718f71

Revision: 7312

Node Kind: directory

Schedule: normal

Last Changed Author: ales

Last Changed Rev: 7194

Last Changed Date: 2009-02-20 12:39:37 +0100 (Fri, 20 Feb 2009)

7 posts
• Page

**1**of**1**