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