Exercise 2 Content-Based Filtering Lab

Hello,

In Practice Lab 2 of Unsupervised Learning Course, Week 2, Deep Learning for Content Based Filtering, I’m struggling with Exercise 2 - Write a function to compute a square distance. This is the code which I use, d = np.square(np.sum((a-b)**2)), and it doesn’t create the expected output. Could anyone help please?

Thank you,
Kind regards,
Anna

Hello @Anna_Evdokimova
Here a and b are numpy arrays so (a-b)**2 won’t give expected results sometime. Also here you have to sum the square of the features so first you have to square features i.e. np.square(a-b) and then take the sum of it i.e. np.sum(np.square(a-b))
Hope this will help to solve your issue in understanding the concept. I would suggest you to once again refer to the video to understand it in more better way.
Please let me know if you have any other issue.
Thank you
Riya