annotate core/tools/machine_learning/scale_ratings.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function Y = scale_ratings(Y, max_weight)
Daniel@0 2 % [Yout, Xout] = scale_ratings(Y, max_weight)
Daniel@0 3
Daniel@0 4
Daniel@0 5 % get maximal weight
Daniel@0 6 weights = cell2mat(Y(:,3));
Daniel@0 7 max_dataweight = max(weights);
Daniel@0 8
Daniel@0 9 valid = ~(cellfun(@isempty, Y(:,1)) | cellfun(@isempty, Y(:,2)));
Daniel@0 10
Daniel@0 11 % scale weights to a maximal value of max_weight
Daniel@0 12 for i = 1:size(Y, 1)
Daniel@0 13 if valid(i) && Y{i,3} > 0
Daniel@0 14 Y{i,3} = min(max_weight, max(1, round((Y{i,3} / max_dataweight) * max_weight)));
Daniel@0 15 end
Daniel@0 16 end