wolffd@0: function w = svmlight2weight(modelfile) wolffd@0: % returns the dual weight vecor for a given svm model wolffd@0: % wolffd@0: % All the script does is compute the weighted sum of the support vectors wolffd@0: % (first element in line is alpha*y, what follows is the feature vector). wolffd@0: % For further info, see the comment in the model file for its format. wolffd@0: wolffd@0: tagstr = python('svmlight2weight.py', modelfile); wolffd@0: wolffd@0: [firstidx] = strfind(tagstr, '1 :'); wolffd@0: wolffd@0: %get start of vector description wolffd@0: tagstr = tagstr(firstidx:end); wolffd@0: wolffd@0: % parse text function output wolffd@0: vecs = textscan(tagstr,'%d %f','Delimiter',':'); wolffd@0: wolffd@0: % initialise wolffd@0: w = zeros(max(vecs{1}),1); wolffd@0: wolffd@0: % set values wolffd@0: w(vecs{1}) = vecs{2}; wolffd@0: