NameError Traceback (most recent call last)

in

11

12 # Evaluate cost function

—> 13 J = cofi_cost_func(X_r, W_r, b_r, Y_r, R_r, 0);

14 print(f"Cost: {J:0.2f}")

in cofi_cost_func(X, W, b, Y, R, lambda_)

31 J += (np.dot(w, x) + b_j - y) ** 2

32

—> 33 J = J / (2 * num_ratings)

34 reg_term = (lambda_ / 2) * (np.sum(W ** 2) + np.sum(X ** 2)) # Remove the b term from regularization

35 J += reg_term

NameError: name ‘num_ratings’ is not defined