lenskit.pipeline.Trainable#

class lenskit.pipeline.Trainable(*args, **kwargs)#

Bases: Protocol

Interface for components that can learn parameters from training data. It supports trainingand checking if a component has already been trained. Trained components need to be picklable.

Note

Trainable components must also implement __call__.

Note

A future LensKit version will add support for extracting model parameters a la Pytorch’s state_dict, but this capability was not ready for 2025.1.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

train(data)

Train the pipeline component to learn its parameters from a training dataset.

Attributes

is_trained

Check if this model has already been trained.

property is_trained: bool#

Check if this model has already been trained.

train(data)#

Train the pipeline component to learn its parameters from a training dataset.

Parameters:
  • data (Dataset) – The training dataset.

  • retrain – If True, retrain the model even if it has already been trained.

Return type:

None