comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function w = svmlight2weight(modelfile)
2 % returns the dual weight vecor for a given svm model
3 %
4 % All the script does is compute the weighted sum of the support vectors
5 % (first element in line is alpha*y, what follows is the feature vector).
6 % For further info, see the comment in the model file for its format.
7
8 tagstr = python('svmlight2weight.py', modelfile);
9
10 [firstidx] = strfind(tagstr, '1 :');
11
12 %get start of vector description
13 tagstr = tagstr(firstidx:end);
14
15 % parse text function output
16 vecs = textscan(tagstr,'%d %f','Delimiter',':');
17
18 % initialise
19 w = zeros(max(vecs{1}),1);
20
21 % set values
22 w(vecs{1}) = vecs{2};
23