recpack.algorithms.loss_functions.bpr_loss_wrapper(X_true: scipy.sparse._csr.csr_matrix, X_pred: scipy.sparse._csr.csr_matrix, batch_size=1000, sample_size=None, exact=False)

Wrapper around bpr_loss() function for use with recpack.algorithms.stopping_criterion.StoppingCriterion.

Positive and negative items are sampled using recpack.algorithms.samplers.BootstrapSampler. Scores are then extracted from the X_pred, and these positive and negative predictions are passed to the bpr_loss() function.

  • X_true (csr_matrix) – The expected interactions for the users

  • X_pred (csr_matrix) – The predicted scores for users

  • batch_size (int, optional) – size of the batches to sample, defaults to 1000

  • sample_size (int, optional) – How many samples to construct

  • exact (bool, optional) – If True sampling happens exact, otherwise sampling assumes high sparsity of data, accepting a minimal amount of false negatives, speeding up sampling without loss of quality, defaults to False


The mean of the losses of sampled pairs

Return type