recbole.evaluator.collector¶
- class recbole.evaluator.collector.Collector(config)[source]¶
Bases:
object
The collector is used to collect the resource for evaluator. As the evaluation metrics are various, the needed resource not only contain the recommended result but also other resource from data and model. They all can be collected by the collector during the training and evaluation process.
This class is only used in Trainer.
- data_collect(train_data)[source]¶
Collect the evaluation resource from training data. :param train_data: the training dataloader which contains the training data. :type train_data: AbstractDataLoader
- eval_batch_collect(scores_tensor: torch.Tensor, interaction, positive_u: torch.Tensor, positive_i: torch.Tensor)[source]¶
Collect the evaluation resource from batched eval data and batched model output. :param scores_tensor: the output tensor of model with the shape of (N, ) :type scores_tensor: Torch.Tensor :param interaction: batched eval data. :type interaction: Interaction :param positive_u: the row index of positive items for each user. :type positive_u: Torch.Tensor :param positive_i: the positive item id for each user. :type positive_i: Torch.Tensor
- eval_collect(eval_pred: torch.Tensor, data_label: torch.Tensor)[source]¶
Collect the evaluation resource from total output and label. It was designed for those models that can not predict with batch. :param eval_pred: the output score tensor of model. :type eval_pred: torch.Tensor :param data_label: the label tensor. :type data_label: torch.Tensor