With the StompChicken fixes (I mistakenly calculated one point product, ugh!), The answer seems to be yes. Since then, I have tested the same problem using a pre-computed kernel with the same correct results. If you use libsvm StompChickens clear, organized computing is a very good check.
The original subject: I am going to start using precomputed kernels in libSVM. I noticed Vlad answered the question, and I thought it would be wise to confirm that libsvm gave the correct answers. I started with unspecified kernels, just a simple linear kernel with 2 classes and three data points in three-dimensional space. I used data
1 1:3 2:1 3:0 2 1:3 2:3 3:1 1 1:7 3:9
The model file created by calling svm-train -s 0 - t 0 contains
svm_type c_svc kernel_type linear nr_class 2 total_sv 3 rho -1.53951 label 1 2 nr_sv 2 1 SV 0.4126650675419768 1:3 2:1 3:0 0.03174528241667363 1:7 3:9 -0.4444103499586504 1:3 2:3 3:1
However, when I calculate the solution manually, this is not what I get. Does anyone know if libsvm is suffering from errors or can someone compare notes and see if they get the same thing as libsvm?
The coefficients a1 , a2 , a3 returned by libsvm should be the values โโthat make
a1 + a2 + a3 - 5*a1*a1 + 12*a1*a2 - 21*a1*a3 - 19*a2*a2/2 + 21*a2*a3 - 65*a3*a3
as far as possible, with restrictions that a1 + a3 = a2 and each of a1 , a2 , a3 should be between 0 and 1 (the default value is C).
The above model file contains the answer
a1 = .412665... a2 = .444410... a3 = .031745...
But you just need to substitute a2 = a1 + a3 in the formula above and confirm that both partial derivatives are equal to zero to see if this solution is correct (since none of a1 , a2 , a3 is 0 or 1), but they are not equal to zero.
Am I doing something wrong or is libsvm giving bad results? (I hope I do something wrong.)