Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Except the python-C++ interface provided, could I use Jython to call libsvm ?

0
Posted

Except the python-C++ interface provided, could I use Jython to call libsvm ?

0

$ export CLASSPATH=$CLASSPATH:~/libsvm-2.4/java/libsvm.jar $ ./jython Jython 2.1a3 on java1.3.0 (JIT: jitc) Type “copyright”, “credits” or “license” for more information. >>> from libsvm import * >>> dir() [‘__doc__’, ‘__name__’, ‘svm’, ‘svm_model’, ‘svm_node’, ‘svm_parameter’, ‘svm_problem’] >>> x1 = [svm_node(index=1,value=1)] >>> x2 = [svm_node(index=1,value=-1)] >>> param = svm_parameter(svm_type=0,kernel_type=2,gamma=1,cache_size=40,eps=0.001,C=1,nr_weight=0,shrinking=1) >>> prob = svm_problem(l=2,y=[1,-1],x=[x1,x2]) >>> model = svm.svm_train(prob,param) * optimization finished, #iter = 1 nu = 1.0 obj = -1.018315639346838, rho = 0.0 nSV = 2, nBSV = 2 Total nSV = 2 >>> svm.svm_predict(model,x1) 1.0 >>> svm.svm_predict(model,x2) -1.0 >>> svm.svm_save_model(“test.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123