emukit.core package

Subpackages

Submodules

class emukit.core.categorical_parameter.CategoricalParameter(name, encoding)

Bases: Parameter

property encodings: ndarray
property model_parameters: List

Gives the list of single dimensional model parameters the parameter corresponds to.

round(x)

Rounds the values of x to fit to the parameter domain, if needed.

Parameters:

x (ndarray) – 2d array of values to be rounded.

Return type:

ndarray

Returns:

A 2d array of rounded values.

property bounds: List[Tuple]

Returns a list of tuples containing where each tuple contains the minimum and maximum of the variables used to encode the categorical parameter..

property dimension: int

Gives the dimension of the parameter.

check_in_domain(x)

Verifies that given values lie within the parameter’s domain

Parameters:

x (ndarray) – 2d numpy array with shape (points, encoding) of points to check

Return type:

bool

Returns:

A boolean value which indicates whether all points lie in the domain

sample_uniform(point_count)

Generates multiple uniformly distributed random parameter points.

Parameters:

point_count (int) – number of data points to generate.

Return type:

ndarray

Returns:

Generated points with shape (point_count, num_features)

class emukit.core.constraints.IConstraint

Bases: object

evaluate(x)
Parameters:

x (ndarray) – Array of shape (n_points x n_dims) containing input locations to evaluate constraint at

Return type:

ndarray

Returns:

Numpy array of shape (n_input,) where an element will be 1 if the corresponding input satisfies the constraint and zero if the constraint is violated

class emukit.core.constraints.InequalityConstraint(lower_bound, upper_bound)

Bases: IConstraint

class emukit.core.constraints.LinearInequalityConstraint(constraint_matrix, lower_bound=None, upper_bound=None)

Bases: InequalityConstraint

Constraint of the form lower_bound <= Ax <= upper_bound where the matrix A is called “constraint_matrix”

evaluate(x)

Evaluate whether constraints are violated or satisfied at a set of x locations

Parameters:

x (ndarray) – Array of shape (n_points x n_dims) containing input locations to evaluate constraint at

Return type:

ndarray

Returns:

Numpy array of shape (n_points, ) where an element will be 1 if the corresponding input satisfies all constraints and zero if any constraint is violated

class emukit.core.constraints.NonlinearInequalityConstraint(constraint_function, lower_bound, upper_bound, jacobian_fun=None)

Bases: InequalityConstraint

Constraint of the form lower_bound <= g(x) <= upper_bound

evaluate(x)

Evaluate whether constraints are violated or satisfied at a set of x locations

Parameters:

x (ndarray) – Array of shape (n_points x n_dims) containing input locations to evaluate constraint at

Return type:

ndarray

Returns:

Numpy array of shape (n_input,) where an element will be 1 if the corresponding input satisfies the constraint and zero if the constraint is violated

class emukit.core.continuous_parameter.ContinuousParameter(name, min_value, max_value)

Bases: Parameter

A univariate continuous parameter with a domain defined in a range between two values

check_in_domain(x)

Checks if all the points in x lie between the min and max allowed values

Parameters:

x (Union[ndarray, float]) – 1d numpy array of points to check or 2d numpy array with shape (n_points, 1) of points to check or float of single point to check

Return type:

bool

Returns:

A boolean value which indicates whether all points lie in the domain

property bounds: List[Tuple]

Returns a list containing one tuple of minimum and maximum values parameter can take

sample_uniform(point_count)

Generates multiple uniformly distributed random parameter points.

Parameters:

point_count (int) – number of data points to generate.

Return type:

ndarray

Returns:

Generated points with shape (point_count, num_features)

class emukit.core.discrete_parameter.DiscreteParameter(name, domain)

Bases: Parameter

A parameter that takes a discrete set of values where the order and spacing of values is important

check_in_domain(x)

Checks if the points in x are in the set of allowed values

Parameters:
  • x (Union[ndarray, Iterable, float]) – 1d numpy array of points to check

  • x – 1d numpy array of points to check or 2d numpy array with shape (n_points, 1) of points to check or Iterable of points to check or float of single point to check

Return type:

bool

Returns:

A boolean indicating whether each point is in domain

property bounds: List[Tuple]

Returns a list containing one tuple of min and max values parameter can take

round(x)

Rounds each row in x to represent a valid value for this discrete variable

Parameters:

x (ndarray) – A 2d array Nx1 to be rounded

Return type:

ndarray

Returns:

An array Nx1 where each row represents a value from the domain that is closest to the corresponding row in x

sample_uniform(point_count)

Generates multiple uniformly distributed random parameter points.

Parameters:

point_count (int) – number of data points to generate.

Return type:

ndarray

Returns:

Generated points with shape (point_count, num_features)

class emukit.core.discrete_parameter.InformationSourceParameter(n_sources)

Bases: DiscreteParameter

class emukit.core.encodings.Encoding(categories, encodings)

Bases: object

Generic class that represents encodings of categorical variables

property dimension: int

Dimension of the encoding

round(x)

Rounds each row in 2d array x to represent one of encodings.

Parameters:

x (ndarray) – A 2d array to be rounded

Return type:

ndarray

Returns:

An array where each row represents an encoding that is closest to the corresponding row in x

round_row(x_row)

Rounds the given row. See “round” method docsting for details.

When subclassing Encoding, it is best to override this method instead of “round”.

Parameters:

x_row – A row to round.

Returns:

A rounded row.

get_category(encoding)

Gets the category corresponding to the encoding.

Parameters:

encoding (Union[List, ndarray]) – An encoded value.

Return type:

str

Returns:

A category.

get_encoding(category)

Gets the encoding corresponding to the category.

Parameters:

category (str) – A category.

Return type:

List

Returns:

An encoding as a list.

class emukit.core.encodings.OneHotEncoding(categories)

Bases: Encoding

round_row(x_row)

Rounds the given row. The highest value is rounded to 1 all other values are rounded to 0

Parameters:

x_row – A row to round.

Returns:

A rounded row.

class emukit.core.encodings.OrdinalEncoding(categories)

Bases: Encoding

round_row(x_row)

Rounds the given row. See “round” method docsting for details.

When subclassing Encoding, it is best to override this method instead of “round”.

Parameters:

x_row – A row to round.

Returns:

A rounded row.

class emukit.core.event_handler.EventHandler(iterable=(), /)

Bases: list

A list of callable objects. Calling an instance of this will cause a call to each item in the list in ascending order by index.

Code taken from: https://stackoverflow.com/a/2022629

To subscribe to the event simply append a function to the event handler: event_handler.append(fcn_to_call_on_event)

class emukit.core.parameter.Parameter(name)

Bases: object

property dimension: int

Gives the dimension of the parameter.

property model_parameters: List

Gives the list of single dimensional model parameters the parameter corresponds to.

property bounds: List[Tuple]

Returns bounds of the parameter in a form of list of tuples

round(x)

Rounds the values of x to fit to the parameter domain, if needed.

Parameters:

x (ndarray) – 2d array of values to be rounded.

Return type:

ndarray

Returns:

A 2d array of rounded values.

check_in_domain(x)

Verifies that given values lie within the parameter’s domain

Parameters:

x (ndarray) – Value to be checked

Return type:

bool

Returns:

A boolean value which indicates whether all points lie in the domain

sample_uniform(point_count)

Generates multiple uniformly distributed random parameter points.

Parameters:

point_count (int) – number of data points to generate.

Return type:

ndarray

Returns:

Generated points with shape (point_count, num_features)

class emukit.core.parameter_space.ParameterSpace(parameters, constraints=None)

Bases: object

Represents parameter space for a given problem.

find_parameter_index_in_model(parameter_name)

Find the indices of the encoding of the specified parameter in the input vector

Parameters:

parameter_name (str) – Parameter name to find indices for

Return type:

List[int]

Returns:

List of indices

property dimensionality
property parameters: List

Returns the list of parameters in the space.

property parameter_names: List

Returns the list of names of parameters in the space.

get_parameter_by_name(name)

Returns parameter with the given name

Parameters:

name (str) – Parameter name

Return type:

Parameter

Returns:

A parameter object

get_bounds()

Returns a list of tuples containing the min and max value each parameter can take.

If the parameter space contains categorical variables, the min and max values correspond to each variable used to encode the categorical variables.

Return type:

List[Tuple]

round(x)

Rounds given values x to closest valid values within the space.

Parameters:

x (ndarray) – A 2d array of values to be rounded

Return type:

ndarray

Returns:

A 2d array of rounded values

check_points_in_domain(x)

Checks that each column of x lies in the domain of the corresponding parameter

Parameters:

x (ndarray) – 2d numpy array of points to check

Return type:

ndarray

Returns:

A 1d numpy array which contains a boolean indicating whether each point is in domain

sample_uniform(point_count)

Generates multiple uniformly distributed random parameter points.

Parameters:

point_count (int) – number of data points to generate.

Return type:

ndarray

Returns:

Generated points with shape (point_count, num_features)

Module contents