lenskit.batch.BatchPipelineRunner#
- class lenskit.batch.BatchPipelineRunner(*, n_jobs=None, use_ray=None, profiler=None, batch_size=None)#
Apply a pipeline to a collection of test users.
- Stability:
- Caller (see Stability Levels).
- Parameters:
n_jobs (int | None)
use_ray (bool | None)
profiler (lenskit.pipeline.PipelineProfiler | None)
batch_size (int | None)
- Argss:
- pipeline:
The pipeline to evaluate.
- n_jobs:
The number of parallel threads to use, or
Nonefor default defined by LensKit configuration and environment variables (see Configuring Parallelism).- use_ray:
Use Ray instead of threads to parallelize batch inference, overriding any option set in an environment variable or
lenskit.toml.- batch_size:
The batch size for multiprocess execution. If
None, a batch size based on the number of inputs is used, with a maximum batch size of 1000.
- profiler: lenskit.pipeline.PipelineProfiler | None#
- invocations: list[InvocationSpec]#
- add_invocation(inv)#
- Parameters:
inv (InvocationSpec)
- score(component='scorer', *, output='scores')#
Request the batch run to generate test item scores.
- predict(component='rating-predictor', *, output='predictions')#
Request the batch run to generate test item rating predictions. It is identical to
score()but with different defaults.
- recommend(component='recommender', *, output='recommendations', **extra)#
Request the batch run to generate recomendations.
- run(pipeline, queries)#
Run the pipeline and return its results.
Note
The runner does not guarantee that results are in the same order as the original inputs.
- Parameters:
pipeline (lenskit.pipeline.Pipeline) – The pipeline to run.
queries (lenskit.batch._queries.BatchInput) – The collection of test queries use. See Batch Queries for details on the various input formats.
- Returns:
The batch results, mapping output names to item list collections of outputs.
- Return type: