def evaluate(model, train_mat, test_mat, config, logger, device): logger.info("Start evaluation") model.eval() device = torch.device(config.device) with torch.no_grad(): user_num, item_num = train_mat.shape # users = torch.from_numpy(np.random.choice(user_num, min(user_num, 5000), False)).to(device) users = np.random.choice(user_num, min(5000, user_num), False) evals = Eval() m = evals.evaluate_item(train_mat[users, :], test_mat[users, :], users, model, device, topk=50) return m
def evaluate(self, train, test): m, n = train.shape u, v = self.get_uv() users = np.random.choice(m, min(m, 50000), False) m = Eval.evaluate_item(train[users, :], test[users, :], u[users, :], v, topk=-1) return m