def slice_recommendations(self, test_data, shape, start, end):
test_tensor_unfolded, slice_idx = self.get_test_tensor(test_data, shape, start, end)
num_users = end - start
num_items = shape[1]
num_fdbks = shape[2]
v = self._items_factors
w = self._feedback_factors
# assume that w.shape[1] < v.shape[1] (allows for more efficient calculations)
scores = test_tensor_unfolded.dot(w).reshape(num_users, num_items, w.shape[1])
scores = np.tensordot(scores, v, axes=(1, 0))
scores = np.tensordot(np.tensordot(scores, v, axes=(2, 1)), w, axes=(1, 1))
scores = self.flatten_scores(scores, self.flattener)
return scores, slice_idx
# additional functionality: rating pediction
评论列表
文章目录