lenskit.data.RecQuery#

class lenskit.data.RecQuery(user_id=None, user_items=None)#

Bases: object

Representation of a the data available for a recommendation query. This is generally the available inputs for a recommendation request except the set of candidate items.

Todo

Document and test methods for extending the recommendation query with arbitrary data to be used by client-provided pipeline components.

Todo

When LensKit supports context-aware recommendation, this should be extended to include context cues.

Parameters:
__init__(user_id=None, user_items=None)#
Parameters:
Return type:

None

Methods

__init__([user_id, user_items])

create(data)

Create a recommenadtion query from an input, filling in available components based on the data type.

Attributes

user_id

The user's identifier.

user_items

The items from the user's interaction history, with ratings if available.

user_id: int | str | bytes | integer[Any] | str_ | bytes_ | object_ | None = None#

The user’s identifier.

user_items: ItemList | None = None#

The items from the user’s interaction history, with ratings if available. This list is deduplicated, like interaction_matrix(), rather than a full interaction log. As with user_row(), the rating is expected to be on a rating field, not score.

classmethod create(data)#

Create a recommenadtion query from an input, filling in available components based on the data type.

Parameters:

data (RecQuery | int | str | bytes | integer[Any] | str_ | bytes_ | object_ | ItemList | None) – Input data to turn into a recommendation query. If the input is already a query, it is returned as-is (not copied).

Returns:

The recommendation query.

Return type:

RecQuery