Deep Learning for Content-Based Filtering problem in assignment

I am facing problem in code -----
Write a function to compute the square distance . please anyone tell me the code

Just handing you the code wouldn’t exactly be ethical. But solving that math formula is fairly straight forward, especially if you use numpy functions. The “Click for Hint” section even makes some suggestions.

The problem can be broken down into 3 parts. 1 part you need to find the difference between the two points in the ndarrays. So you’ll want to compare a to b and calculate the difference. After you calculate that you need the square that difference. That will give you the square distance for 1 item in the array. The last thing you need to do is sum all of the differences in the array.

It could probably be written using loops, but it would be slow. I suggest reading the hint, and if need be reading the documentation for those numpy functions and see how you could combine them to solve the square distance problem.

I found this link by googling for numpy documentation: Numpy Reference

Hello @Shashi_Rathore,

I think @RyanCarr has covered every useful aspect of it, but since I have written a post about that too, so I just would like to share it with you and hope it would bring more thoughts in.

Here it is:

Happy new year!
Raymond

I tried with the following code but its not working
{code removed by mentor}

since you said it isn’t working, I suppose you had run the tests on your function but encountered some errors. Can you share a screenshot of the full error trackback or any error message here?

I am a little bit tied up now, so I will check it out later today or other mentors might get back to you.

Thanks,
Raymond

{code removed by mentor}

Hello @Shashi_Rathore,

The error indicates that you didn’t indent your code correctly. You might read this guide on indentation or google the error messages for more details about it. You are implementing a function, and you will need to figure out how to indent to make codes part of a function.

Cheers,
Raymond

PS: I am removing your code since it isn’t allowed to share it here. Next time, please post only the error traceback. Thank you.

Thank you so much . I understood this concept now.

1 Like

Thank you so much for clearing the doubts.