lenskit.basic.candidates#

Classes

AllTrainingItemsCandidateSelector([config])

Candidate selector that selects all known items from the training data.

TrainingCandidateSelectorBase([config])

Base class for candidate selectors using the training data.

TrainingItemsCandidateConfig([exclude])

Configuration for TrainingItemsCandidateSelector.

TrainingItemsCandidateSelector([config])

Candidate selector that selects all known items from the training data, optionally excluding certain items from the query (i.e., the request user's history).

UnratedTrainingItemsCandidateSelector([config])

Candidate selector that selects all known items from the training data that do not appear in the request user's history (RecQuery.history_items).

class lenskit.basic.candidates.TrainingCandidateSelectorBase(config=None, **kwargs)#

Bases: Component[ItemList, …], Trainable

Base class for candidate selectors using the training data.

Stability:
Caller (see Stability Levels).
Parameters:
  • config (None)

  • kwargs (Any)

items_: Vocabulary#

List of known items from the training data.

train(data, options=TrainingOptions(retrain=True, device=None, rng=None))#

Train the model to learn its parameters from a training dataset.

Parameters:
class lenskit.basic.candidates.AllTrainingItemsCandidateSelector(config=None, **kwargs)#

Bases: TrainingCandidateSelectorBase

Candidate selector that selects all known items from the training data.

Deprecated since version 2025.6: Use TrainingItemsCandidateSelector with None for TrainingItemsCandidateConfig.exclude instead.

Stability:
Caller (see Stability Levels).
Parameters:
  • config (None)

  • kwargs (Any)

class lenskit.basic.candidates.UnratedTrainingItemsCandidateSelector(config=None, **kwargs)#

Bases: TrainingCandidateSelectorBase

Candidate selector that selects all known items from the training data that do not appear in the request user’s history (RecQuery.history_items). If no item history is available, then all training items are returned.

In order to look up the user’s history in the training data, this needs to be combined with a component like UserTrainingHistoryLookup.

Deprecated since version 2025.6: Use TrainingItemsCandidateSelector with default settings or the "history" option for TrainingItemsCandidateConfig.exclude instead.

Stability:
Caller (see Stability Levels).
Parameters:
  • config (None)

  • kwargs (Any)

class lenskit.basic.candidates.TrainingItemsCandidateConfig(exclude='query')#

Bases: object

Configuration for TrainingItemsCandidateSelector.

Parameters:

exclude (None | Literal['query', 'all', 'history', 'session', 'context'] | ~collections.abc.Sequence[~typing.Literal['history', 'session', 'context']])

exclude: None | Literal['query', 'all', 'history', 'session', 'context'] | Sequence[Literal['history', 'session', 'context']] = 'query'#

Specify the items from the query to exclude from the candidates.

None

Exclude no items from the request.

"query"

Excludes the query items (RecQuery.query_items) from the request. This is the default.

"all"

Exclude all mentioned items from the request.

"history", "session", "context"

Exclude the specified items from the request.

class lenskit.basic.candidates.TrainingItemsCandidateSelector(config=None, **kwargs)#

Bases: TrainingCandidateSelectorBase

Candidate selector that selects all known items from the training data, optionally excluding certain items from the query (i.e., the request user’s history).

In order to look up the user’s history in the training data, this needs to be combined with a component like UserTrainingHistoryLookup.

Stability:
Caller (see Stability Levels).
Parameters: