lenskit.pipeline.TrainableComponent#
- class lenskit.pipeline.TrainableComponent(*args, **kwargs)#
Bases:
Generic
[COut
],Protocol
Interface for pipeline components that can learn parameters from training data, and expose those parameters for serialization as an alternative to pickling (components also need to be picklable).
Note
Trainable components must also implement
__call__
.- __init__(*args, **kwargs)#
Methods
__init__
(*args, **kwargs)Get the model's learned parameters for serialization.
load_params
(params)Reload model state from parameters saved via
get_params()
.train
(data)Train the pipeline component to learn its parameters from a training dataset.
- train(data)#
Train the pipeline component to learn its parameters from a training dataset.
- get_params()#
Get the model’s learned parameters for serialization.
LensKit components that learn parameters from training data should both implement this method and work when pickled and unpickled. Pickling is sometimes used for convenience, but parameter / state dictionaries allow serializing wtih tools like
safetensors
.
- load_params(params)#
Reload model state from parameters saved via
get_params()
.