diff --git a/machine-learning-ex8/ex8/cofiCostFunc.m b/machine-learning-ex8/ex8/cofiCostFunc.m index 00f45ab..1f24deb 100644 --- a/machine-learning-ex8/ex8/cofiCostFunc.m +++ b/machine-learning-ex8/ex8/cofiCostFunc.m @@ -40,20 +40,11 @@ Theta_grad = zeros(size(Theta)); % partial derivatives w.r.t. to each element of Theta % - - - - - - - - - - - - - - +t1 = (Theta*X')'; +t2 = (t1-Y).^2; +t3 = t2(R==1); +temp = sum(t3(:)); +J = (1/2) * (temp); % ============================================================= diff --git a/machine-learning-ex8/ex8/ex8_cofi.m b/machine-learning-ex8/ex8/ex8_cofi.m index d8f224f..57baa20 100644 --- a/machine-learning-ex8/ex8/ex8_cofi.m +++ b/machine-learning-ex8/ex8/ex8_cofi.m @@ -40,7 +40,7 @@ ylabel('Movies'); xlabel('Users'); fprintf('\nProgram paused. Press enter to continue.\n'); -pause; +% pause; %% ============ Part 2: Collaborative Filtering Cost Function =========== % You will now implement the cost function for collaborative filtering. @@ -66,7 +66,7 @@ fprintf(['Cost at loaded parameters: %f '... '\n(this value should be about 22.22)\n'], J); fprintf('\nProgram paused. Press enter to continue.\n'); -pause; +% pause; %% ============== Part 3: Collaborative Filtering Gradient ============== diff --git a/machine-learning-ex8/ex8/token.mat b/machine-learning-ex8/ex8/token.mat index 323ae30..9b10b2d 100644 Binary files a/machine-learning-ex8/ex8/token.mat and b/machine-learning-ex8/ex8/token.mat differ