Hyperparam#

This class provides a way to define hyperparameters for a machine learning model.

class mloptimizer.domain.hyperspace.Hyperparam(name: str, min_value: int, max_value: int, hyperparam_type: str, scale: int = 100, values_str: list = None)[source]#

Bases: object

Class to define a hyperparam to optimize. It defines the name, min value, max value and type. This is used to control the precision of the hyperparam and avoid multiple evaluations with close values of the hyperparam due to decimal positions.

name#

Name of the hyperparam. It will be used as key in a dictionary

Type:

str

min_value#

Minimum value of the hyperparam

Type:

int

max_value#

Maximum value of the hyperparam

Type:

int

hyperparam_type#

Type of the hyperparam (‘int’, ‘float’, ‘nexp’, ‘x10’, ‘list’)

Type:

str

scale#

Optional param in case the type=float

Type:

int, optional (default=100)

values_str#

List of string with possible values. Used when the hyperparam_type=’list’

Type:

list, optional (default=[])

Creates object Hyperparam.

Parameters:
  • name (str) – Name of the hyperparam. It will be used as key in a dictionary

  • min_value (int) – Minimum value of the hyperparam

  • max_value (int) – Maximum value of the hyperparam

  • hyperparam_type (str) – Type of the hyperparam (‘int’, ‘float’, ‘nexp’, ‘x10’, ‘list’)

  • scale (int, optional (default=100)) – Optional param in case the hyperparam_type=’float’

  • values_str (list, optional (default=[])) – List of string with possible values. Used when the hyperparam_type=’list’

correct(value: int)[source]#
Returns the real value of the hyperparam in case some mutation could surpass the limits.
  1. Verifies the input is int

  2. Enforce min and max value

  3. Apply the type of value

Parameters:

value (int) – Value to correct

Returns:

ret – Corrected value

Return type:

int, float, str

classmethod from_values_list(name: str, values_str: list)[source]#

Alternative constructor for creating a Hyperparam instance from a list of fixed values.

Parameters:
  • name (str) – Name of the hyperparam. It will be used as a key in a dictionary.

  • values_str (list) – List of fixed values for the hyperparam.

Returns:

An instance of the Hyperparam class configured with the provided fixed values.

Return type:

Hyperparam