lenskit.training.UsesTrainer#

class lenskit.training.UsesTrainer(config=None, **kwargs)#

Bases: lenskit.pipeline.components.Component, abc.ABC, Trainable

Base class for models that implement Trainable via a ModelTrainer.

The component’s configuration must have an epochs attribute defining the number of epochs to train.

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

  • kwargs (Any)

trained_epochs: int = 0#
property expected_training_epochs: int | None#

Get the number of training epochs expected to run. The default implementation looks for an epochs attribute on the configuration object (self.config).

Return type:

int | None

is_trained()#

Query if this component has already been trained.

train(data, options=TrainingOptions())#

Implementation of Trainable.train() that uses the model trainer.

Parameters:
Return type:

None

abstractmethod create_trainer(data, options)#

Create a model trainer to train this model.

Parameters:
Return type:

ModelTrainer