UNQ_C17 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
def hash_value_of_vector(v, planes):
“”"Create a hash for a vector; hash_id says which random hash to use.
Input:
- v: vector of tweet. It’s dimension is (1, N_DIMS)
- planes: matrix of dimension (N_DIMS, N_PLANES) - the set of planes that divide up the region
Output:
- res: a number which is used as a hash for your vector
"""
### START CODE HERE ###
# for the set of planes,
# calculate the dot product between the vector and the matrix containing the planes
# remember that planes has shape (300, 10)
# The dot product will have the shape (1,10)
dot_product = np.dot(v,planes)
# get the sign of the dot product (1,10) shaped vector
sign_of_dot_product = np.sign(dot_product)
# set h to be false (eqivalent to 0 when used in operations) if the sign is negative,
# and true (equivalent to 1) if the sign is positive (1,10) shaped vector
# if the sign is 0, i.e. the vector is in the plane, consider the sign to be positive
h = None
# remove extra un-used dimensions (convert this from a 2D to a 1D array)
h = None
# initialize the hash value to 0
hash_value = 0
n_planes = None
for i in range(n_planes):
# increment the hash value by 2^i * h_i
hash_value += None
### END CODE HERE ###
# cast hash_value as an integer
hash_value = int(hash_value)
return hash_value
I am not able to complete this function.