lenskit.batch.TestRequestAdapter#

class lenskit.batch.TestRequestAdapter(lists, *, items_as='test')#

Bases: collections.abc.Iterable[BatchRecRequest], collections.abc.Sized

Wrapper for an item list collection that interprets it as a collection of test requests. Iterating over this collection will yield the requests in the same order they are in the underlying item list collection.

The user_id and query_id key fields, if present are used to construct the recommendation queries. If there is no query_id field, then the entire key is used as a query ID. The item lists themselves are interpreted as directed by the items_as option:

test

Items are used as test items (e.g., the items for which to predict ratings), but not candidates.

candidates

Items are used as candidate lists.

both

Items are used as both test items and candidates.

None

Items are excluded.

Parameters:
  • lists (lenskit.data.ItemListCollection) – The item list collection.

  • items_as (Literal['test', 'candidates', 'both'] | None) – Where to put the item lists in the request.

Warns:

DataWarning – If the item list collection cannot be used to construct usable requests.

Stability:
Caller (see Stability Levels).
lists: lenskit.data.ItemListCollection#
item_use: Literal['test', 'candidates', 'both'] | None#
__len__()#
__iter__()#
Return type:

collections.abc.Iterator[BatchRecRequest]