smac.epm.gaussian_process.utils.prior

Classes

GammaPrior(a, scale, loc, rng)

HorseshoePrior(scale, rng)

LognormalPrior(sigma, rng[, mean])

Prior(rng)

Abstract base class to define the interface for priors of GP hyperparameter.

SoftTopHatPrior(lower_bound, upper_bound, ...)

TophatPrior(lower_bound, upper_bound, rng)

class smac.epm.gaussian_process.utils.prior.GammaPrior(a, scale, loc, rng)[source]

Bases: smac.epm.gaussian_process.utils.prior.Prior

class smac.epm.gaussian_process.utils.prior.HorseshoePrior(scale, rng)[source]

Bases: smac.epm.gaussian_process.utils.prior.Prior

class smac.epm.gaussian_process.utils.prior.LognormalPrior(sigma, rng, mean=0)[source]

Bases: smac.epm.gaussian_process.utils.prior.Prior

class smac.epm.gaussian_process.utils.prior.Prior(rng)[source]

Bases: object

Abstract base class to define the interface for priors of GP hyperparameter.

This class is adapted from RoBO:

Klein, A. and Falkner, S. and Mansur, N. and Hutter, F. RoBO: A Flexible and Robust Bayesian Optimization Framework in Python In: NIPS 2017 Bayesian Optimization Workshop

[16.04.2019]: Whenever lnprob or the gradient is computed for a scalar input, we use math.* rather than np.*

Parameters

rng (np.random.RandomState) – Random number generator

gradient(theta)[source]

Computes the gradient of the prior with respect to theta.

Theta must be on the original scale.

Parameters

theta (float) – Hyperparameter configuration in log space

Returns

The gradient of the prior at theta.

Return type

float

lnprob(theta)[source]

Return the log probability of theta.

Theta must be on a log scale! This method exponentiates theta and calls self._lnprob.

Parameters

theta (float) – Hyperparameter configuration in log space.

Returns

The log probability of theta

Return type

float

sample_from_prior(n_samples)[source]

Returns n_samples from the prior.

All samples are on a log scale. This method calls self._sample_from_prior and applies a log transformation to the obtained values.

Parameters

n_samples (int) – The number of samples that will be drawn.

Return type

np.ndarray

class smac.epm.gaussian_process.utils.prior.SoftTopHatPrior(lower_bound, upper_bound, exponent, rng)[source]

Bases: smac.epm.gaussian_process.utils.prior.Prior

gradient(theta)[source]

Returns the gradient of the prior at theta.

Return type

float

lnprob(theta)[source]

Return the log probability of theta.

Return type

float

class smac.epm.gaussian_process.utils.prior.TophatPrior(lower_bound, upper_bound, rng)[source]

Bases: smac.epm.gaussian_process.utils.prior.Prior

gradient(theta)[source]

Computes the gradient of the prior with respect to theta.

Parameters

theta (float) – Hyperparameter configuration in log space

Returns

The gradient of the prior at theta.

Return type

  1. np.array