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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started