Spotify-inspired recommendation prototype uses nearby embedding vectors to infer a label from similar items. You need to find the training item most similar to the query by cosine similarity and return its class so the team can validate the retrieval baseline.
Find the training vector most similar to the query by cosine similarity and return its class. If several vectors tie, the first one wins; a vector with zero length has similarity 0 to everything.
Implement solve(X, y, q).
Returns. Return the label (an element of y) of the most similar training row.
Example 1
Input:
solve([[1, 0], [0, 1]], ['A', 'B'], [0.9, 0.1])
Output:
'A'
Example 2
Input:
solve([[1, 0], [1, 1], [0, 1]], ['x', 'y', 'z'], [0.1, 1.0])
Output:
'z'
No results yet
Run your code to check it against the examples, or submit to run every test.