lenskit.pipeline.ConfigurableComponent#

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

Bases: Protocol

Interface for configurable pipeline components (those that have hyperparameters). A configurable component supports two additional operations:

  • saving its configuration with get_config().

  • creating a new instance from a saved configuration with the class method from_config().

A component must implement both of these methods to be considered configurable. For most common cases, extending the AutoConfig class is sufficient to provide working implementations of these methods.

If a component is not configurable, then it should either be a function or a class that can be constructed with no arguments.

Note

Configuration data should be JSON-compatible (strings, numbers, etc.).

Note

Implementations must also implement __call__.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

from_config(cfg)

Reinstantiate this component from configuration values.

get_config()

Get this component's configured hyperparameters.

classmethod from_config(cfg)#

Reinstantiate this component from configuration values.

Parameters:

cfg (dict[str, Any])

Return type:

Self

get_config()#

Get this component’s configured hyperparameters.

Return type:

dict[str, object]