The predictions module

The surprise.prediction_algorithms.predictions module defines the Prediction named tuple and the PredictionImpossible exception.

class surprise.prediction_algorithms.predictions.Prediction

A named tuple for storing the results of a prediction.

It’s wrapped in a class, but only for documentation and printing purposes.

Parameters:
  • uid – The (raw) user id. See this note.
  • iid – The (raw) item id. See this note.
  • r_ui (float) – The true rating \(r_{ui}\).
  • est (float) – The estimated rating \(\hat{r}_{ui}\).
  • details (dict) – Stores additional details about the prediction that might be useful for later analysis.
exception surprise.prediction_algorithms.predictions.PredictionImpossible

Exception raised when a prediction is impossible.

When raised, the estimation \(\hat{r}_{ui}\) is set to the global mean of all ratings \(\mu\).