Moving course1 to course1 subdir.
This commit is contained in:
17
machine_learning/course1/mlclass-ex8-008/mlclass-ex8/normalizeRatings.m
Executable file
17
machine_learning/course1/mlclass-ex8-008/mlclass-ex8/normalizeRatings.m
Executable file
@@ -0,0 +1,17 @@
|
||||
function [Ynorm, Ymean] = normalizeRatings(Y, R)
|
||||
%NORMALIZERATINGS Preprocess data by subtracting mean rating for every
|
||||
%movie (every row)
|
||||
% [Ynorm, Ymean] = NORMALIZERATINGS(Y, R) normalized Y so that each movie
|
||||
% has a rating of 0 on average, and returns the mean rating in Ymean.
|
||||
%
|
||||
|
||||
[m, n] = size(Y);
|
||||
Ymean = zeros(m, 1);
|
||||
Ynorm = zeros(size(Y));
|
||||
for i = 1:m
|
||||
idx = find(R(i, :) == 1);
|
||||
Ymean(i) = mean(Y(i, idx));
|
||||
Ynorm(i, idx) = Y(i, idx) - Ymean(i);
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user