lenskit.basic.candidates#

Classes#

TrainingItemsCandidateConfig

Configuration for TrainingItemsCandidateSelector.

TrainingItemsCandidateSelector

Candidate selector that selects all known items from the training data, optionally

Module Contents#

class lenskit.basic.candidates.TrainingItemsCandidateConfig#

Configuration for TrainingItemsCandidateSelector.

exclude: None | Literal['query', 'all', 'history', 'session', 'context'] | collections.abc.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: lenskit.pipeline.Component[lenskit.data.ItemList], lenskit.training.Trainable

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:
  • config (object | None)

  • kwargs (Any)

config: TrainingItemsCandidateConfig#

The component configuration object. Component classes that support configuration must redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class.

items: lenskit.data.Vocabulary#

List of known items from the training data.

is_trained()#

Query if this component has already been trained.

train(data, options=TrainingOptions())#

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

Parameters:
__call__(query)#

Run the pipeline’s operation and produce a result. This is the key method for components to implement.

Parameters:

query (lenskit.data.QueryInput)

Return type:

lenskit.data.ItemList

Exported Aliases#

class lenskit.basic.candidates.Dataset#

Re-exported alias for lenskit.data.Dataset.

class lenskit.basic.candidates.ItemList#

Re-exported alias for lenskit.data.ItemList.

lenskit.basic.candidates.QueryInput#

Re-exported alias for lenskit.data.QueryInput.

class lenskit.basic.candidates.RecQuery#

Re-exported alias for lenskit.data.RecQuery.

class lenskit.basic.candidates.Vocabulary#

Re-exported alias for lenskit.data.Vocabulary.

class lenskit.basic.candidates.Component#

Re-exported alias for lenskit.pipeline.Component.

class lenskit.basic.candidates.Trainable#

Re-exported alias for lenskit.training.Trainable.

class lenskit.basic.candidates.TrainingOptions#

Re-exported alias for lenskit.training.TrainingOptions.