Hi,

I am stuck at the Collaborative Filtering Recommendation System assignment. I was able to get the right output with regularization, but am unsure where should I add the regularization term? I am getting the wrong output when I add the regularization term.

the regularization term is add it to the regular cost(just addition operation) like this equation

\underbrace{
\frac{\lambda}{2}
\sum_{j=0}^{n_u-1}\sum_{k=0}^{n-1}(\mathbf{w}^{(j)}_k)^2+ \frac{\lambda}{2}\sum_{i=0}^{n_m-1}\sum_{k=0}^{n-1}(\mathbf{x}_k^{(i)})^2
}_{regularization}

I did, I added the regularization term and got the following error:

AssertionError Traceback (most recent call last)

in

1 # Public tests

2 from public_tests import *

----> 3 test_cofi_cost_func(cofi_cost_func)

~/work/public_tests.py in test_cofi_cost_func(target)

14 J = target(X_r, W_r, b_r, Y_r, R_r, 2);

15 assert not np.isclose(J, 13.5), f"Wrong value. Got {J}. Did you multiply the regularization term by lambda_?"

—> 16 assert np.isclose(J, 27), f"Wrong value. Expected {27}, got {J}. Check the regularization term"

17

18

AssertionError: Wrong value. Expected 27, got 270.0. Check the regularization term

The issue is resolved. Thanks