lenskit.batch#

Batch-run recommendation pipelines for evaluation.

Attributes#

BatchInput

Allowed input types for batch inference routines.

Classes#

BatchRecRequest

Full recommendation request for batch inference, including candidate items.

TestRequestAdapter

Wrapper for an item list collection that interprets it as a collection of

BatchResults

Results from a batch recommendation run. Results consist of the outputs of

BatchPipelineRunner

Apply a pipeline to a collection of test users.

InvocationSpec

Specification for a single pipeline invocation, to record one or more

Functions#

predict(…)

Convenience function to batch-generate rating predictions (or other per-item

recommend(…)

Convenience function to batch-generate recommendations from a pipeline. This

Package Contents#

type lenskit.batch.BatchInput = Iterable[BatchRecRequest] | Iterable[RecQuery] | Iterable[ID | GenericKey] | ItemListCollection[GenericKey]#

Allowed input types for batch inference routines.

lenskit.batch.predict[K: lenskit.data.GenericKey](pipeline: lenskit.pipeline.Pipeline, test: lenskit.data.ItemListCollection[K], *, n_jobs: int | None = None, use_ray: bool | None = None) lenskit.data.ItemListCollection[K]#
lenskit.batch.predict(pipeline: lenskit.pipeline.Pipeline, test: _queries.BatchInput, *, n_jobs: int | None = None, use_ray: bool | None = None) lenskit.data.ItemListCollection[lenskit.data.GenericKey]

Convenience function to batch-generate rating predictions (or other per-item scores) from a pipeline. This is a batch version of lenskit.predict(), and is a convenience wrapper around using a BatchPipelineRunner() to generate predictions.

Note

If test is just a sequence of IDs, this method will still work, but it will score _all candidate items_ for each of the IDs.

Stability:
Caller (see Stability Levels).
lenskit.batch.recommend[K: lenskit.data.GenericKey](pipeline: lenskit.pipeline.Pipeline, queries: lenskit.data.ItemListCollection[K], n: int | None = None, *, n_jobs: int | None = None, use_ray: bool | None = None, profiler: lenskit.pipeline.PipelineProfiler | None = None, users=None) lenskit.data.ItemListCollection[K]#
lenskit.batch.recommend(pipeline: lenskit.pipeline.Pipeline, queries: _queries.BatchInput, n: int | None = None, *, n_jobs: int | None = None, use_ray: bool | None = None, profiler: lenskit.pipeline.PipelineProfiler | None = None, users=None) lenskit.data.ItemListCollection[lenskit.data.GenericKey]

Convenience function to batch-generate recommendations from a pipeline. This is a batch version of lenskit.recommend(), and is a convenience wrapper around using a BatchPipelineRunner() to generate recommendations.

See also

BatchPipelineRunner.run() for details on the arguments, and Batch Queries for details on the valid inputs for queries.

Parameters:

queries – The request queries.

Stability:
Caller (see Stability Levels).

Exported Aliases#

lenskit.batch.GenericKey#

Re-exported alias for lenskit.data.GenericKey.

class lenskit.batch.ItemListCollection#

Re-exported alias for lenskit.data.ItemListCollection.

class lenskit.batch.Pipeline#

Re-exported alias for lenskit.pipeline.Pipeline.

class lenskit.batch.PipelineProfiler#

Re-exported alias for lenskit.pipeline.PipelineProfiler.