lenskit.implicit#

Bridges to recommendation models from implicit.

Classes#

BaseRec

Base class for Implicit-backed recommenders.

ALS

LensKit interface to implicit.cpu.als (or GPU version).

BPR

LensKit interface to implicit.cpu.bpr (or GPU version).

Module Contents#

class lenskit.implicit.BaseRec(config=None, **kwargs)#

Bases: lenskit.pipeline.Component[lenskit.data.ItemList], lenskit.training.Trainable

Base class for Implicit-backed recommenders.

Stability:
Caller (see Stability Levels).
Parameters:
  • config (object | None)

  • kwargs (Any)

config: ImplicitConfig#

The component configuration object. Component classes that support configuration must redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class.

weight: float = 1.0#
matrix: scipy.sparse.csr_matrix#

The user-item rating matrix from training.

users: lenskit.data.Vocabulary#

The user ID mapping from training.

items: lenskit.data.Vocabulary#

The item ID mapping from training.

user_embeddings: numpy.typing.NDArray[numpy.float32]#
item_embeddings: numpy.typing.NDArray[numpy.float32]#
is_trained()#

Query if this component has already been trained.

train(data, options=TrainingOptions())#

Train the model to learn its parameters from a training dataset.

Parameters:
__call__(query, items)#

Run the pipeline’s operation and produce a result. This is the key method for components to implement.

Parameters:
Return type:

lenskit.data.ItemList

class lenskit.implicit.ALS(config=None, **kwargs)#

Bases: BaseRec

LensKit interface to implicit.cpu.als (or GPU version).

Stability:
Caller (see Stability Levels).
Parameters:
  • config (object | None)

  • kwargs (Any)

config: ImplicitALSConfig#

The component configuration object. Component classes that support configuration must redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class.

property weight#
class lenskit.implicit.BPR(config=None, **kwargs)#

Bases: BaseRec

LensKit interface to implicit.cpu.bpr (or GPU version).

Stability:
Caller (see Stability Levels).
Parameters:
  • config (object | None)

  • kwargs (Any)

Exported Aliases#

class lenskit.implicit.Dataset#

Re-exported alias for lenskit.data.Dataset.

class lenskit.implicit.ItemList#

Re-exported alias for lenskit.data.ItemList.

lenskit.implicit.QueryInput#

Re-exported alias for lenskit.data.QueryInput.

class lenskit.implicit.RecQuery#

Re-exported alias for lenskit.data.RecQuery.

class lenskit.implicit.Vocabulary#

Re-exported alias for lenskit.data.Vocabulary.

lenskit.implicit.ensure_parallel_init()#

Re-exported alias for lenskit.parallel.config.ensure_parallel_init().

lenskit.implicit.get_parallel_config()#

Re-exported alias for lenskit.parallel.config.get_parallel_config().

class lenskit.implicit.Component#

Re-exported alias for lenskit.pipeline.Component.

class lenskit.implicit.Trainable#

Re-exported alias for lenskit.training.Trainable.

class lenskit.implicit.TrainingOptions#

Re-exported alias for lenskit.training.TrainingOptions.