AnneS
AnneS

Reputation: 1583

How to get weights of SVM from GUI of Weka?

I am using the WEKA GUI to classification. I incorporated LibSVM library to use the linear kernel of LibSVM. Now in addition to the performance results, I also want to see the exact weights in this linear kernal. Do anyone know if there is a way to do this? I searched and got nothing so far.

Upvotes: 2

Views: 766

Answers (1)

carlosdc
carlosdc

Reputation: 12152

The formula is this: $w = \sum_i(\alpha_i x_i)$, where \alpha_i is the Langrangian multiplier and x_i is the support vector. I've never done that inside of WEKA, but this is how you do it in MATLAB, hopefully it will be fairly self explanatory and you can easily reproduce this code from WEKA, in the end we're using the same library (LIBSVM):

function [w b] = generate_w_b(model)
w = zeros(size(model.SVs,2),1);
for i=1:size(model.SVs,1),
    w = w+model.sv_coef(i)*model.SVs(i,:)';
end
b = model.rho;

Upvotes: 2

Related Questions