lenskit.tuning.spec#

Attributes#

Classes#

SearchConfig

Configuration options for the hyperparameter search.

TuningSpec

Data model for hyperparameter tuning specifications.

PipelineFile

Load a pipeline from a file.

SearchParam

Module Contents#

lenskit.tuning.spec.SearchSpace#
class lenskit.tuning.spec.SearchConfig#

Bases: pydantic.BaseModel

Configuration options for the hyperparameter search.

method: Literal['optuna', 'hyperopt', 'random'] | None = None#

The search method to use.

max_points: int | None = None#

The maximum number of points to try.

default_points: int = 60#

The default number of search points, if not limited by a maximum configuration.

max_epochs: int = 100#

The maximum number of epochs to use in iterative training.

min_epochs: int = 3#

The minimum number of epochs for iterative training.

metric: str | None = None#

The metric to use.

list_length: int | None = None#

The length of recommendation lists to use.

num_cpus: int | Literal['threads', 'all-threads'] = 'threads'#

The number of CPUs to request from Ray Tune.

num_gpus: int | float = 0#

The number of GPUs to requrest from Ray Tune.

checkpoint_iters: int = 2#

The frequency for saving checkpoints.

update_max_points(n)#

Limit the search points to a new maximum, if it exceeds the current maximum.

Parameters:

n (int | None)

num_search_points()#

Get the number of search points to use.

Return type:

int

class lenskit.tuning.spec.TuningSpec#

Bases: pydantic.BaseModel

Data model for hyperparameter tuning specifications.

classmethod load(path)#
Parameters:

path (pathlib.Path)

Return type:

TuningSpec

file_path: Annotated[pathlib.Path | None, Field(exclude=True)] = None#

The path to the spec file.

search: SearchConfig#

Options for the hyperparameter search.

space: dict[str, SearchSpace]#

The search space for tuning.

pipeline: PipelineFile | lenskit.pipeline.config.PipelineConfig#

The pipeline to tune.

property component_name: str | None#

Get the name of the tuned component, if the search specifies parameters for a single component.

Return type:

str | None

resolve_path(path)#

Resolve a path relative to this specification’s file.

Parameters:

path (pathlib.Path | str)

Return type:

pathlib.Path

class lenskit.tuning.spec.PipelineFile#

Bases: pydantic.BaseModel

Load a pipeline from a file.

file: pathlib.Path#

The file from whic to load the pipeline.

class lenskit.tuning.spec.SearchParam#

Bases: pydantic.BaseModel

type: Literal['int', 'float']#

The type of this parameter.

min: int | float#

Minimum parameter value.

max: int | float#

Maximum parameter value.

scale: Literal['uniform', 'log'] = 'uniform'#

Search scale for parameter values.

base: float | None = None#

Base for logarithmic search scales.

Exported Aliases#

lenskit.tuning.spec.lenskit_config()#

Re-exported alias for lenskit.config.lenskit_config().

lenskit.tuning.spec.load_config_data()#

Re-exported alias for lenskit.config.load_config_data().

class lenskit.tuning.spec.PipelineConfig#

Re-exported alias for lenskit.pipeline.config.PipelineConfig.