Orange Forum • View topic - Selecting SVM kernel types

Selecting SVM kernel types

A place to ask questions about methods in Orange and how they are used and other general support.

Selecting SVM kernel types

Postby Guest » Wed Mar 11, 2009 11:42

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:

(quoted from:
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/ 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

Postby Guest » Fri Mar 13, 2009 11:04

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:

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
>>> 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!

Postby Ales » Tue Mar 17, 2009 13:02

The name changes happened quite some time ago. Run in orange installation directory on windows or rebuild from latest svn source on linux, to fix the naming issue.

I also updated the documentation of the default svm_type.

Postby Guest » Wed Mar 18, 2009 10:29

I have the 1.0 version of Orange on Ubuntu 7.10.

I did a svn up, make clean; make, and recopied the relevant files to /usr/lib/python2.5/site-packages/orange.

However, I still have the same issue with the naming. Is the fix perhaps only the daily snapshot?

Postby Ales » Wed Mar 18, 2009 12:26

In the 1.0 version the constants should still all be in upper case.
Are you sure you have sources checked out from and not from the trunk?

Postby Guest » Wed Mar 18, 2009 14:40

I think so, svn info gives me:

Code: Select all
Path: .
Repository Root:
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)

Postby Blaz » Thu Mar 19, 2009 14:04

You should really switch to the "daily snapshot". Daily snapshot is in fact 2.0beta, and there are many more things there than in 1.0. Albeit it is beta, it is passing most (if not all) of the regression tests, so it is rather stable as well.

Return to Questions & Support