Skip to content

Integrated acquisition function

smac.acquisition.function.integrated_acquisition_function #

IntegratedAcquisitionFunction #

IntegratedAcquisitionFunction(
    acquisition_function: AbstractAcquisitionFunction,
)

Bases: AbstractAcquisitionFunction

Compute the integrated acquisition function by marginalizing over model hyperparameters

See "Practical Bayesian Optimization of Machine Learning Algorithms" by Jasper Snoek et al. (papers.nips.cc/paper/4522-practical-bayesian-optimization-of-machine-learning-algorithms.pdf) for further details.

PARAMETER DESCRIPTION
acquisition_function

Acquisition function to be integrated.

TYPE: AbstractAcquisitionFunction

ATTRIBUTE DESCRIPTION
_acquisition_function

Acquisition function to be integrated.

TYPE: AbstractAcquisitionFunction

_functions

Holds n (n = number of models) copies of the acquisition function.

TYPE: list[AbstractAcquisitionFunction]

_eta

Current incumbent function value.

TYPE: float

Source code in smac/acquisition/function/integrated_acquisition_function.py
def __init__(self, acquisition_function: AbstractAcquisitionFunction) -> None:
    super().__init__()
    self._acquisition_function: AbstractAcquisitionFunction = acquisition_function
    self._functions: list[AbstractAcquisitionFunction] = []
    self._eta: float | None = None

model property writable #

model: AbstractModel | None

Return the used surrogate model in the acquisition function.

__call__ #

__call__(configurations: list[Configuration]) -> ndarray

Compute the acquisition value for a given configuration.

PARAMETER DESCRIPTION
configurations

The configurations where the acquisition function should be evaluated.

TYPE: list[Configuration]

RETURNS DESCRIPTION
ndarray[N, 1]

Acquisition values for X

Source code in smac/acquisition/function/abstract_acquisition_function.py
def __call__(self, configurations: list[Configuration]) -> np.ndarray:
    """Compute the acquisition value for a given configuration.

    Parameters
    ----------
    configurations : list[Configuration]
        The configurations where the acquisition function should be evaluated.

    Returns
    -------
    np.ndarray [N, 1]
        Acquisition values for X
    """
    X = convert_configurations_to_array(configurations)
    if len(X.shape) == 1:
        X = X[np.newaxis, :]

    acq = self._compute(X)
    if np.any(np.isnan(acq)):
        idx = np.where(np.isnan(acq))[0]
        acq[idx, :] = -np.finfo(float).max

    return acq

update #

update(model: AbstractModel, **kwargs: Any) -> None

Update the acquisition function attributes required for calculation.

This method will be called after fitting the model, but before maximizing the acquisition function. As an examples, EI uses it to update the current fmin. The default implementation only updates the attributes of the acquisition function which are already present.

Calls _update to update the acquisition function attributes.

PARAMETER DESCRIPTION
model

The model which was used to fit the data.

TYPE: AbstractModel

kwargs

Additional arguments to update the specific acquisition function.

TYPE: Any DEFAULT: {}

Source code in smac/acquisition/function/abstract_acquisition_function.py
def update(self, model: AbstractModel, **kwargs: Any) -> None:
    """Update the acquisition function attributes required for calculation.

    This method will be called after fitting the model, but before maximizing the acquisition
    function. As an examples, EI uses it to update the current fmin. The default implementation only updates the
    attributes of the acquisition function which are already present.

    Calls `_update` to update the acquisition function attributes.

    Parameters
    ----------
    model : AbstractModel
        The model which was used to fit the data.
    kwargs : Any
        Additional arguments to update the specific acquisition function.
    """
    self.model = model
    self._update(**kwargs)