Mercurial > hg > camir-aes2014
annotate core/tools/machine_learning/scale_ratings.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 Y = scale_ratings(Y, max_weight) |
wolffd@0 | 2 % [Yout, Xout] = scale_ratings(Y, max_weight) |
wolffd@0 | 3 |
wolffd@0 | 4 |
wolffd@0 | 5 % get maximal weight |
wolffd@0 | 6 weights = cell2mat(Y(:,3)); |
wolffd@0 | 7 max_dataweight = max(weights); |
wolffd@0 | 8 |
wolffd@0 | 9 valid = ~(cellfun(@isempty, Y(:,1)) | cellfun(@isempty, Y(:,2))); |
wolffd@0 | 10 |
wolffd@0 | 11 % scale weights to a maximal value of max_weight |
wolffd@0 | 12 for i = 1:size(Y, 1) |
wolffd@0 | 13 if valid(i) && Y{i,3} > 0 |
wolffd@0 | 14 Y{i,3} = min(max_weight, max(1, round((Y{i,3} / max_dataweight) * max_weight))); |
wolffd@0 | 15 end |
wolffd@0 | 16 end |