Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (19k points)

I am in dire need of a classification task example using LibSVM in python. I don't know how the Input should look like and which function is responsible for training and which one for testing Thanks

1 Answer

0 votes
by (33.1k points)

LIBSVM is used to read the data from a tuple containing two lists. The first list contains the classes and the second list contains the input data. You can create a simple dataset with two possible classes you also need to specify which kernel you want to use by creating svm_parameter.
 

>> from libsvm import *

>> prob = svm_problem([1,-1],[[1,0,1],[-1,0,-1]])

>> param = svm_parameter(kernel_type = LINEAR, C = 10)

  ## training  the model

>> m = svm_model(prob, param)

#testing the model

>> m.predict([1, 1, 1])

Hope this answer helps.

If you want to learn Python visit this Python course.

Browse Categories

...