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