Batch-Running Recommendations

The lenskit.batch module contains support for batch-running recommender and predictor algorithms. This is often used as part of a recommender evaluation experiment.

Rating Prediction

lenskit.batch.predict(algo, pairs, model=None)

Generate predictions for user-item pairs. The provided algorithm should be a algorithms.Predictor or a function of two arguments: the user ID and a list of item IDs. It should return a dictionary or a pandas.Series mapping item IDs to predictions.

Parameters:
  • or (predictor(callable) – py:class:algorithms.Predictor): a rating predictor function or algorithm.
  • pairs (pandas.DataFrame) – a data frame of (user, item) pairs to predict for. If this frame also contains a rating column, it will be included in the result.
  • model (any) – a model for the algorithm.
Returns:

a frame with columns user, item, and prediction containing the prediction results. If pairs contains a rating column, this result will also contain a rating column.

Return type:

pandas.DataFrame