wolffd@0: function [Yout, Xout] = mlr_repeat_YX_by_rating(Y, X, weights) wolffd@0: % [Yout, Xout] = mlr_repeat_YX_by_rating(Y, X, weights) wolffd@0: % wolffd@0: % repeats the data in X and Y according to the weights specified wolffd@0: % in weights or Y(:,3) wolffd@0: wolffd@0: cprint(2, 'Repeating data for weighted learning'); wolffd@0: if nargin == 2 wolffd@0: weights = cell2mat(Y(:,3)); wolffd@0: end wolffd@0: wolffd@0: Yout = Y(:,1:2); wolffd@0: wolffd@0: valid = ~(cellfun(@isempty, Y(:,1)) | cellfun(@isempty, Y(:,2))); wolffd@0: wolffd@0: for i = 1:size(Y, 1) wolffd@0: if valid(i) wolffd@0: for j = 2:weights(i) wolffd@0: Yout(end + 1, :) = Y(i, 1:2); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: Xout = zeros(size(X,1), size(Y,1)); wolffd@0: Xout(:,1:size(X,2)) = X; wolffd@0: for i = 1:size(Y, 1) wolffd@0: if valid(i) wolffd@0: for j = 2:weights(i) wolffd@0: Xout(:,end+1) = X(:,i); wolffd@0: end wolffd@0: end wolffd@0: end