Question: Problem 3 : For this HW, you will be asked to implement it in Python. 1. Create two lists for x and y where x
Problem 3 : For this HW, you will be asked to implement it in Python.
1. Create two lists for x and y where x = [0, 2, 0, 0, 0, 6, 0, 3, 0, 0] and y = [3, 0, 0, 0, 1, 0, 0, 4, 0, 2]
2. Using a for loop to calculate inner product of x and y, and the norm for x and y by iterating each element in x and y
3. Calculate the cosine similarity by the inner product and the norm You are free to use other steps. But note: you are NOT allowed to use Numpy or Pandas packages to directly get the cosine similarity, but you can use np.sqrt or other function to help you do the math operations).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
