VariableTransformer#
- class pybads.variable_transformer.VariableTransformer(D, lower_bounds: ndarray = None, upper_bounds: ndarray = None, plausible_lower_bounds: ndarray = None, plausible_upper_bounds: ndarray = None, apply_log_t=None, fixed_values: ndarray = None)[source]#
A class enabling linear or non-linear transformation of the bounds (plausible_lower_bounds and plausible_upper_bounds) and map them to an hypercube [-1, 1]^D
- Parameters:
- Dint
The dimension of the space.
- lower_boundsnp.ndarray, optional
The lower bounds of the space.
lower_boundsandupper_boundsdefine a set of strict lower and upper bounds for each variable, given in the original space. By default None, which is-inf.- upper_boundsnp.ndarray, optional
The upper bounds of the space.
lower_boundsandupper_boundsdefine a set of strict lower and upper bounds for each variable, given in the original space. By default None, which isinf.- plausible_lower_boundsnp.ndarray, optional
The plausible lower bounds such that
lower_bounds <= plausible_lower_bounds < plausible_upper_bounds <= upper_bounds.plausible_lower_boundsandplausible_upper_boundsrepresent a “plausible” range for each variable, given in the original space, and need to be finite. By default None, which islower_bounds.- plausible_upper_boundsnp.ndarray, optional
The plausible upper bounds such that
lower_bounds <= plausible_lower_bounds < plausible_upper_bounds <= upper_bounds.plausible_lower_boundsandplausible_upper_boundsrepresent a “plausible” range for each variable, given in the original space, and need to be finite. By default None, which isupper_bounds.- apply_log_tnp.ndarray, optional
A boolean array of shape
(1, D)that indicates the variables to which the non-linear log transformation applies; a scalar applies to every variable. By default None, in which case the log transformation is applied if the bounds are all positive and the plausible box spans at least one order of magnitude (pub/plb >= 10), as it is to a variable whose entry is NaN.- fixed_valuesnp.ndarray, optional
The values of the fixed variables of a problem, when the transform is of its other variables: one value per variable of the original space, of shape
(1, D_orig)or(D_orig,), NaN at each of theDvariables that the bounds describe, in their order, and the value elsewhere.inverse_transfthen returns points of theD_origvariables, with the fixed ones at their values, and__call__takes such points and transforms their other coordinates. By default None, which, as a row of NaN, fixes no variable: the original space has theDvariables of the bounds.- Each bound is an array of ``D`` elements, of shape ``(1, D)`` or
- ``(D,)``, or a scalar or an array of one element, which stands for the
- same bound in each dimension; bounds of integers are taken as floats.
- Attributes:
- D_origint
The number of variables of the original space:
Dand the fixed variables.- fixed_valuesnp.ndarray or None
fixed_valuesas a row of shape(1, D_orig), or None when it fixes no variable.
- Raises:
- ValueError
When a bound is not a number or an array of numbers, or is neither a scalar nor an array of one or
Delements, when the plausible bounds are not finite or the bounds are out of the order above, or when the transform cannot be inverted at the bounds.- ValueError
When
fixed_valuesis not a row of numbers, NaN at exactlyDof them and finite at the others.
- __call__(input: ndarray)[source]#
Performs direct transform of original variables
inputinto the hypercube space.- Parameters:
- inputnp.ndarray
A N x D array, where N is the number of input data and D is the number of dimensions; N x D_orig with
fixed_values, whose fixed coordinates are left out.
- Returns:
- unp.ndarray
The variables transformed.
- inverse_transf(input: ndarray)[source]#
Performs inverse transform of the transformed variables
inputin the hypercube into the original space.- Parameters:
- inputnp.ndarray
The transformed variables that will be mapped in the original space.
- Returns:
- xnp.ndarray
The original variables retrieved by the inverse transform; with
fixed_values, allD_origof them, the fixed ones at their values.