HyperparameterSpaceBuilder#
The HyperparameterSpaceBuilder class provides tools to define and construct hyperparameter search spaces for optimization.
- class mloptimizer.interfaces.HyperparameterSpaceBuilder[source]#
Bases:
objectA builder class for constructing hyperparameter spaces.
This class is responsible for defining both fixed and evolvable hyperparameters, allowing for the construction of a HyperparameterSpace object used in optimization tasks.
Initializes the builder with empty dictionaries for both fixed and evolvable hyperparameters. Also initializes an instance of HyperparameterSpaceService to manage space-related operations.
- add_categorical_param(name: str, values: list)[source]#
Adds a categorical parameter to the evolvable hyperparameters.
- Parameters:
- Returns:
self – The builder instance, allowing for method chaining.
- Return type:
- add_float_param(name: str, min_value: int, max_value: int, scale=100)[source]#
Adds a float parameter to the evolvable hyperparameters.
- Parameters:
- Returns:
self – The builder instance, allowing for method chaining.
- Return type:
- add_int_param(name: str, min_value: int, max_value: int)[source]#
Adds an integer parameter to the evolvable hyperparameters.
- Parameters:
- Returns:
self – The builder instance, allowing for method chaining.
- Return type:
- build()[source]#
Builds the HyperparameterSpace object using the current configuration.
- Returns:
The constructed hyperparameter space containing both fixed and evolvable parameters.
- Return type:
- static get_default_space(estimator_class)[source]#
Returns a default hyperparameter space using the HyperparameterSpaceService.
- Parameters:
estimator_class (class) – The estimator class for which the default hyperparameter space should be retrieved.
- Returns:
A default hyperparameter space for the given estimator class.
- Return type:
- load_default_space(estimator_class)[source]#
Load a default hyperparameter space using the HyperparameterSpaceService.
- Parameters:
estimator_class (class) – The estimator class for which the default hyperparameter space should be loaded.
- Returns:
A default hyperparameter space for the given estimator class.
- Return type:
- load_space(hyperparam_space_json_path)[source]#
Load a hyperparameter space from a JSON file using the HyperparameterSpaceService.
- Parameters:
hyperparam_space_json_path (str) – The path to the JSON file containing the hyperparameter space.
- Returns:
The loaded hyperparameter space.
- Return type:
- save_space(hyperparam_space, file_path, overwrite=False)[source]#
Save the hyperparameter space using the HyperparameterSpaceService.
- Parameters:
hyperparam_space (HyperparameterSpace) – The hyperparameter space to be saved.
file_path (str) – The file path where the hyperparameter space should be saved.
overwrite (bool, optional) – Whether to overwrite an existing file (default is False).
- Return type:
None
- set_fixed_param(name: str, value)[source]#
Sets a fixed parameter with the given name and value.
- Parameters:
name (str) – The name of the parameter.
value (any) – The fixed value to assign to the parameter.
- Returns:
self – The builder instance, allowing for method chaining.
- Return type: