matlab - libsvm with precomputed kernel: How do I compute the classification scores? -


I am working with libsvm in MATLAB and a 1-vs all SVM in the precompiled non-linear kernels. I'm a bit new to SVM and I'm trying to calculate the function function. I know that for a linear SVM, we can get (according to libsvm documentation) accordingly:
  w = model sv_coef '* model.SVs;   

We can then calculate decision values:

  w '* x   

and later , Can be guessed, labeling, where is there is some limit; signature (w '* x + b) .

I am particularly interested in getting the classification scores from my non-linear kernel. How can I go about this?

I'm trying to understand what you mean by the classification score Compare the possibility, and choose the largest one, as I did in you

If you are using function function, then it is also fine. Suppose you are using RBF kernel, and model.Label (1) = 1 , then you have (if model.Label (1) = -1 , Then w = -w; b = -b; )

  [m, n] = size (model.SVs); % M is the number of support vectors, ... and the number of n features is w = model sv_coef; % M * 1 weight vector B = -model.ro; % Scalar   

You are now given under the v test. And you have [1, n] = size (v); Then in the i support vector for each valve, calculate Euclidean distance (you can deflect the code given below): i = 1 (i) = ideal for model (ssv (i, :) -v); T (I) = XP (-Gam * D (I). ^ 2); % RBF model, T1 * m vector end

and decision function (or score from function function):

  s = t * W + b ;   

You can get function functions along with other non-linear kernels. Edit

With the written precomponed kernel, for example, the RBF kernel is taken:

 < Code>% RBF kernel: XP (-Gam * * UV | ^ 2) RBF = @ (X, Y) XP (-Gm. * Pdist2 (X, Y, 'Euclidean'). ^ 2); The sample with serial matrix is ​​required as the first column in the form of serial number K_train = [(1: numTrain) ', RBF (train data, train data)]; K_test = [(1: numTest) ', RBF (TestData, Train Data)]; % # Train and test model = svmtrain (train labels, ktrain, '-4 4); [Pradelabel, ~, ~] = svmpredict (testlabel, k_test, model); % # Illusion matrix C = confusion (test label, predLabel);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -