I have made the code according to the equation and verified with the hints. Before adding the regularization term i got index error. Now i add the regularization term, got type error.
Hi @VANI_M
The error say that you returned string values .First you want to do an nested for loop out one is over number of feature do you have(nu) insider loop over the number of training examples do you have(nm) in the nested loop you computer the target values is dot product of sample X[i,:] , W[i,:] plus b[0,j] minus the real value Y[i,j] and compute square of this result after that multiply it with rate of[i,j] to make sure that the user j has rated the movie i or not and doing sum over this results after the end of the for loop and before the return you compute the regularization term which is the sum over all weights W2 (squared) and sum over all training X2 (squared) and multiply it with lambda and plus this term with the total cost you computed in the for and divide it by 2 like this equation
-
Note please make sure from indentation of the nested for loop
also the total hint is there if you want
Cheers!
Abdelrahman
I applied the same code… i am getting 144… bigger value
Please check this post out.
Raymond
PS: Next time, please just open a new thread for your own question, instead of writing replies in multiple threads.