pred.m 356 B

123456789101112131415
  1. function [pred_out] = pred(w1_M1_sample,w1_P1_sample,N,mean_rating);
  2. %%% Make predicitions on the validation data
  3. aa_p = double(N(:,1));
  4. aa_m = double(N(:,2));
  5. rating = double(N(:,3));
  6. pred_out = sum(w1_M1_sample(aa_m,:).*w1_P1_sample(aa_p,:),2) + mean_rating;
  7. ff = find(pred_out>5); pred_out(ff)=5;
  8. ff = find(pred_out<1); pred_out(ff)=1;