mloptimizer.hyperparams.hyperspace#

Module Contents#

Classes#

HyperparameterSpace

This class represents the hyperparameter space for a scikit-learn classifier. It contains the fixed hyperparameters

class mloptimizer.hyperparams.hyperspace.HyperparameterSpace(fixed_hyperparams: dict, evolvable_hyperparams: dict)[source]#

This 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 Hyperparam class.

fixed_hyperparams#

Dictionary with the fixed hyperparameters

Type:

dict

evolvable_hyperparams#

Dictionary with the evolvable hyperparameters of Hyperparam instances

Type:

dict

default_hyperparameter_spaces_json[source]#
classmethod from_json(file_path)[source]#

This method creates a HyperparameterSpace object 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

to_json(file_path, overwrite=False)[source]#

This method saves the hyperparameter space as a JSON file.

Parameters:
  • file_path (str) – Path to the JSON file

  • overwrite (bool, optional (default=False)) – If True, the file will be overwritten if it exists. If False, a FileExistsError will be raised if the file exists

Raises:
  • ValueError – If the file path is None

  • FileExistsError – If the file exists and overwrite is False

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