lenskit.batch.BatchPipelineRunner#

class lenskit.batch.BatchPipelineRunner(*, n_jobs=None, profiler=None)#

Bases: object

Apply a pipeline to a collection of test users.

Stability:
Caller (see Stability Levels).
Parameters:
  • n_jobs (int | Literal['ray'] | None)

  • profiler (PipelineProfiler | None)

Argss:
pipeline:

The pipeline to evaluate.

n_jobs:

The number of parallel processes to use, or None for the default (defined by lenskit.parallel.config.initialize()).

__init__(*, n_jobs=None, profiler=None)#
Parameters:
  • n_jobs (int | Literal['ray'] | None)

  • profiler (PipelineProfiler | None)

Methods

__init__(*[, n_jobs, profiler])

add_invocation(inv)

predict([component, output])

Request the batch run to generate test item rating predictions.

recommend([component, output])

Request the batch run to generate recomendations.

run()

Run the pipeline and return its results.

score([component, output])

Request the batch run to generate test item scores.

Attributes

n_jobs

profiler

invocations

score(component='scorer', *, output='scores')#

Request the batch run to generate test item scores.

Parameters:
  • component (str) – The name of the rating predictor component to run.

  • output (str) – The name of the results in the output dictionary.

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.

Parameters:
  • component (str) – The name of the rating predictor component to run.

  • output (str) – The name of the results in the output dictionary.

recommend(component='recommender', *, output='recommendations', **extra)#

Request the batch run to generate recomendations.

Parameters:
  • component (str) – The name of the recommender component to run.

  • output (str) – The name of the results in the output dictionary.

  • extra (Any) – Extra inputs to the recommender. A common option is n, the number of recommendations to return (a default may be baked into the pipeline).

run(pipeline: Pipeline, queries: Iterable[RecQuery] | Iterable[tuple[RecQuery, ItemList]] | Iterable[int | str | bytes | integer[Any] | str_ | bytes_ | object_ | tuple[int | str | bytes | integer[Any] | str_ | bytes_ | object_, ...]] | ItemListCollection[tuple[int | str | bytes | integer[Any] | str_ | bytes_ | object_, ...]] | Mapping[int | str | bytes | integer[Any] | str_ | bytes_ | object_, ItemList] | DataFrame) BatchResults#
run(pipeline: Pipeline, *, test_data: Iterable[int | str | bytes | integer[Any] | str_ | bytes_ | object_ | tuple[int | str | bytes | integer[Any] | str_ | bytes_ | object_, ...]] | ItemListCollection[tuple[int | str | bytes | integer[Any] | str_ | bytes_ | object_, ...]] | Mapping[int | str | bytes | integer[Any] | str_ | bytes_ | object_, ItemList] | DataFrame) BatchResults

Run the pipeline and return its results.

Parameters:
  • pipeline – The pipeline to run.

  • queries – The collection of test queries use. See Batch Queries for details on the various input formats.

Returns:

The results, as a nested dictionary. The outer dictionary maps component output names to inner dictionaries of result data.