recpack.algorithms.loss_functions.warp_loss_wrapper(X_true: scipy.sparse._csr.csr_matrix, X_pred: scipy.sparse._csr.csr_matrix, batch_size: int = 1000, num_negatives: int = 20, margin: float = 1.9, sample_size=None, exact=False)

Metric wrapper around the warp_loss() function.

Positives and negatives are sampled from the X_true matrix using recpack.algorithms.samplers.WarpSampler. Their scores are fetched from the X_pred matrix.

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

  • X_pred (csr_matrix) – Predicted scores.

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

  • num_negatives (int, optional) – How many negatives to sample for each positive item, defaults to 20

  • margin (float, optional) – required margin between positives and negatives, defaults to 1.9

  • 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. This speeds up sampling without significant loss of quality, defaults to False


The warp loss

Return type