lenskit.basic.history#

Components that look up user history from the training data.

Classes

KnownRatingScorer([score, source])

Score items by returning their values from the training data.

UserTrainingHistoryLookup(*args, **kwargs)

Look up a user's history from the training data.

class lenskit.basic.history.UserTrainingHistoryLookup(*args, **kwargs)#

Bases: Component, Trainable

Look up a user’s history from the training data.

property is_trained: bool#

Check if this model has already been trained.

train(data)#

Train the pipeline component to learn its parameters from a training dataset.

Parameters:
  • data (Dataset) – The training dataset.

  • retrain – If True, retrain the model even if it has already been trained.

class lenskit.basic.history.KnownRatingScorer(score=None, source='training')#

Bases: Component, Trainable

Score items by returning their values from the training data.

Parameters:
  • score (Literal['rating', 'indicator'] | None) – Whether to score items with their rating values, or a 0/1 indicator of their presence in the training data. The default (None) uses ratings if available, and otherwise scores with 1 for interacted items and leaves non-interacted items unscored.

  • source (Literal['training', 'query']) – Whether to use the training data or the user’s history represented in the query as the source of score data.

property is_trained: bool#

Check if this model has already been trained.

train(data)#

Train the pipeline component to learn its parameters from a training dataset.

Parameters:
  • data (Dataset) – The training dataset.

  • retrain – If True, retrain the model even if it has already been trained.