Monday, April 11, 2011

libsvm python example

In this post we see on how to install and use LIBSVM using python.

My other posts on libsvm will be posted here.

For intro to classification, click here.
The following is the easiest way to install libsvm python module in Ubuntu.

 $sudo apt-get install python-libsvm

In order to use it, use the following program sample:



This again reminds me on how simple python is!!!
Cheers!!

3 comments:

  1. Hi,

    I was testing this your code and in error saying that the variable 'kernel_type' is unexpected:

    """TypeError: __ init__ () got an unexpected keyword argument 'kernel_type'"""

    What should I do?

    ReplyDelete
  2. That is weird. which version of libsvm-python are you using? I'm using libsvm 2.90-1 on Ubuntu 10.04 LTS and the above code works just fine.

    ReplyDelete
  3. I get the same error, and after working around it using
    param = svm_parameter()
    param.kernel_type = LINEAR
    param.C = 10
    I get an error about svm_model(problem, param):
    TypeError: __init__() takes exactly 1 argument (3 given)

    ReplyDelete