Mercurial > hg > camir-aes2014
annotate core/tools/machine_learning/svmlight2weight.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function w = svmlight2weight(modelfile) |
wolffd@0 | 2 % returns the dual weight vecor for a given svm model |
wolffd@0 | 3 % |
wolffd@0 | 4 % All the script does is compute the weighted sum of the support vectors |
wolffd@0 | 5 % (first element in line is alpha*y, what follows is the feature vector). |
wolffd@0 | 6 % For further info, see the comment in the model file for its format. |
wolffd@0 | 7 |
wolffd@0 | 8 tagstr = python('svmlight2weight.py', modelfile); |
wolffd@0 | 9 |
wolffd@0 | 10 [firstidx] = strfind(tagstr, '1 :'); |
wolffd@0 | 11 |
wolffd@0 | 12 %get start of vector description |
wolffd@0 | 13 tagstr = tagstr(firstidx:end); |
wolffd@0 | 14 |
wolffd@0 | 15 % parse text function output |
wolffd@0 | 16 vecs = textscan(tagstr,'%d %f','Delimiter',':'); |
wolffd@0 | 17 |
wolffd@0 | 18 % initialise |
wolffd@0 | 19 w = zeros(max(vecs{1}),1); |
wolffd@0 | 20 |
wolffd@0 | 21 % set values |
wolffd@0 | 22 w(vecs{1}) = vecs{2}; |
wolffd@0 | 23 |