跳到内容

概率提升

smac.acquisition.function.probability_improvement #

PI #

PI(xi: float = 0.0)

基类:AbstractAcquisitionFunction

提升概率(Probability of Improvement)

:math:P(f_{t+1}(\mathbf{X})\geq f(\mathbf{X^+})) :math::= \Phi(\\frac{ \mu(\mathbf{X})-f(\mathbf{X^+}) } { \sigma(\mathbf{X}) }) 其中 :math:f(X^+) 是当前的最佳值,:math:\Phi 是标准正态分布的累积分布函数(cdf)。

参数#

xi:浮点数,默认为 0.0。控制采集函数的探索与利用之间的平衡。

源代码位于 smac/acquisition/function/probability_improvement.py
def __init__(self, xi: float = 0.0):
    super(PI, self).__init__()
    self._xi: float = xi
    self._eta: float | None = None

model 属性 可写 #

model: AbstractModel | None

返回采集函数中使用的代理模型。

__call__ #

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

计算给定配置的采集值。

参数#

configurations:list[Configuration]。应评估采集函数的配置。

返回#

np.ndarray [N, 1]。X 的采集值。

源代码位于 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

更新计算所需的采集函数属性。

此方法将在拟合模型后但在最大化采集函数之前调用。例如,EI 使用它来更新当前的 fmin。默认实现仅更新采集函数中已有的属性。

调用 _update 更新采集函数属性。

参数#

model:AbstractModel。用于拟合数据的模型。kwargs:Any。更新特定采集函数的附加参数。

源代码位于 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)