C3_W2_Collaborative_RecSys_Assignment.ipynb
When I run Public test, the following error generated but no clue.
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 0.0. Check the regularization term
The code for cofi_cost_func is as follows:
GRADED FUNCTION: cofi_cost_func
UNQ_C1
def cofi_cost_func(X, W, b, Y, R, lambda_):
“”"
Returns the cost for the content-based filtering
Args:
X (ndarray (num_movies,num_features)): matrix of item features
W (ndarray (num_users,num_features)) : matrix of user parameters
b (ndarray (1, num_users) : vector of user parameters
Y (ndarray (num_movies,num_users) : matrix of user ratings of movies
R (ndarray (num_movies,num_users) : matrix, where R(i, j) = 1 if the i-th movies was rated by the j-th user
lambda_ (float): regularization parameter
Returns:
J (float) : Cost
“”"
nm, nu = Y.shape
J = 0
### START CODE HERE ###
Posting codes related to grade cell can cause your membership at the discourse community, so kindly follow code of conduct and refrain from posting grade cell codes in future. Refer FAQ section, Code of Conduct section for details
### END CODE HERE ###
return J