recbole.evaluator.utils

recbole.evaluator.utils.cutoff(scores, threshold)[source]

cut of the scores based on threshold

Parameters
  • scores (numpy.ndarray) – scores

  • threshold (float) – between 0 and 1

Returns

processed scores

Return type

numpy.ndarray

recbole.evaluator.utils.pad_sequence(sequences, len_list, pad_to=None, padding_value=0)[source]

pad sequences to a matrix

Parameters
  • sequences (list) – list of variable length sequences.

  • len_list (list) – the length of the tensors in the sequences

  • pad_to (int, optional) – if pad_to is not None, the sequences will pad to the length you set, else the sequence will pad to the max length of the sequences.

  • padding_value (int, optional) – value for padded elements. Default: 0.

Returns

[seq_num, max_len] or [seq_num, pad_to]

Return type

torch.Tensor

recbole.evaluator.utils.trunc(scores, method)[source]

Round the scores by using the given method

Parameters
  • scores (numpy.ndarray) – scores

  • method (str) – one of [‘ceil’, ‘floor’, ‘around’]

Raises

NotImplementedError – method error

Returns

processed scores

Return type

numpy.ndarray