comparison core/tools/machine_learning/mlr_repeat_YX_by_rating.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 [Yout, Xout] = mlr_repeat_YX_by_rating(Y, X, weights)
2 % [Yout, Xout] = mlr_repeat_YX_by_rating(Y, X, weights)
3 %
4 % repeats the data in X and Y according to the weights specified
5 % in weights or Y(:,3)
6
7 cprint(2, 'Repeating data for weighted learning');
8 if nargin == 2
9 weights = cell2mat(Y(:,3));
10 end
11
12 Yout = Y(:,1:2);
13
14 valid = ~(cellfun(@isempty, Y(:,1)) | cellfun(@isempty, Y(:,2)));
15
16 for i = 1:size(Y, 1)
17 if valid(i)
18 for j = 2:weights(i)
19 Yout(end + 1, :) = Y(i, 1:2);
20 end
21 end
22 end
23
24 Xout = zeros(size(X,1), size(Y,1));
25 Xout(:,1:size(X,2)) = X;
26 for i = 1:size(Y, 1)
27 if valid(i)
28 for j = 2:weights(i)
29 Xout(:,end+1) = X(:,i);
30 end
31 end
32 end