All problems
Rocchio Query Update Vector
Problem
The Rocchio update moves the query toward relevant document centroids and away from nonrelevant ones: alpha q + beta rel - gamma nonrel.
Given the query vector, the relevant centroid, the nonrelevant centroid, and the weights, return the updated query.
Hint
Combine the three weighted vectors coordinatewise.
Test cases
case 1
in: [[1,0],[1,1],[0,0],1,0.5,0.25]
expected: [1.5,0.5]
case 2
in: [[0,1],[0,0],[1,0],1,0.8,0.2]
expected: [-0.2,1]
case 3
in: [[1,1],[1,1],[1,1],1,1,1]
expected: [1,1]
Starter codePython
def rocchio_query_update_vector(query, relevant_centroid, nonrelevant_centroid, alpha, beta, gamma):
# Your code here
pass3 test cases · run your code against them in the editor