HyperparameterSpace#
This class provides a way to define search spaces for hyperparameters.
- class mloptimizer.domain.hyperspace.HyperparameterSpace(fixed_hyperparams: dict, evolvable_hyperparams: dict)[source]#
Bases:
objectThis class represents the hyperparameter space for a scikit-learn classifier. It contains the fixed hyperparameters and the evolvable hyperparameters. The fixed hyperparameters are just a dictionary with the hyperparameters that are not going to be optimized and their value. The evolvable hyperparameters are a dictionary with the hyperparameters that are going to be optimized. The keys are the hyperparameter names and the values are instances of the
Hyperparamclass.- evolvable_hyperparams#
Dictionary with the evolvable hyperparameters of
Hyperparaminstances- Type:
Constructs all the necessary attributes for the HyperparameterSpace object.
- Parameters:
- default_hyperparameter_spaces_json = '/home/docs/checkouts/readthedocs.org/user_builds/mloptimizer/checkouts/master/mloptimizer/domain/hyperspace/../../infrastructure/config/hyperspace/default_hyperparameter_spaces.json'#
- classmethod from_json(file_path)[source]#
This method creates a
HyperparameterSpaceobject from a JSON file.- Parameters:
file_path (str) – Path to the JSON file
- Return type:
HyperparameterSpace- Raises:
FileNotFoundError – If the file does not exist
json.JSONDecodeError – If the file is not a valid JSON file
- classmethod from_json_data(json_data)[source]#
Create a HyperparameterSpace object from a dictionary (JSON data).
- Parameters:
json_data (dict) – Dictionary containing the hyperparameter space data.
- Returns:
An instance of HyperparameterSpace.
- Return type:
- get_all_params()[source]#
This method returns a dictionary with all the hyperparameters, fixed and evolvable.
- Returns:
Dictionary with all the hyperparameters
- Return type:
- static get_default_hyperparameter_space(estimator_class)[source]#
This method returns a dictionary with the default hyperparameters for the scikit-learn classifier. It reads the default_hyperparameter_spaces.json file and returns the hyperparameters for the classifier
- Parameters:
estimator_class (class) – The scikit-learn classifier class
- Returns:
The hyperparameter space for the classifier
- Return type:
HyperparameterSpace
- to_json(file_path, overwrite=False)[source]#
This method saves the hyperparameter space as a JSON file.
- Parameters:
- Raises:
ValueError – If the file path is None
FileExistsError – If the file exists and overwrite is False