LibSVM v3.1 python example: (many older examples break in v3.1)
from svmutil import *
svm_model.predict = lambda self, x: svm_predict([0], [x], self)[0][0]
prob = svm_problem([1,-1], [[1,0,1], [-1,0,-1]])
param = svm_parameter()
param.kernel_type = LINEAR
param.C = 10
m=svm_train(prob, param)
m.predict([1,1,1])
From: http://stackoverflow.com/questions/4214868/an-example-using-libsvm-in-python/4215056
Wow, thanks
ReplyDeleteIndeed, most of the previous examples break
svm_model.predict = lambda self, x: svm_predict([0], [x], self)[0][0]
ReplyDelete???????
What does this do
???????