aepsych.acquisition

Submodules

aepsych.acquisition.bvn module

aepsych.acquisition.bvn.bvn_cdf(xu, yu, r)[source]

Evaluate the bivariate normal CDF.

WARNING: Implements only the routine for moderate levels of correlation. Will be inaccurate and should not be used for correlations larger than 0.925.

Standard (mean 0, var 1) bivariate normal distribution with correlation r. Evaluated from -inf to xu, and -inf to yu.

Based on function developed by Alan Genz: http://www.math.wsu.edu/faculty/genz/software/matlab/bvn.m

based in turn on Drezner, Z and G.O. Wesolowsky, (1989), On the computation of the bivariate normal inegral, Journal of Statist. Comput. Simul. 35, pp. 101-107.

Parameters:
  • xu (torch.Tensor) – Upper limits for cdf evaluation in x

  • yu (torch.Tensor) – Upper limits for cdf evaluation in y

  • r (torch.Tensor) – BVN correlation

Returns:

Tensor of cdf evaluations of same size as xu, yu, and r.

Return type:

Tensor

aepsych.acquisition.lookahead module

aepsych.acquisition.lookahead.Hb(p)[source]

Binary entropy.

Parameters:

p (torch.Tensor) – torch.Tensor of probabilities.

Return type:

Tensor

Returns: Binary entropy for each probability.

aepsych.acquisition.lookahead.MI_fn(Px, P1, P0, py1)[source]

Average mutual information. H(p) - E_y*[H(p | y*)]

Parameters:
  • Px (torch.Tensor) – (b x m) Level-set posterior before observation

  • P1 (torch.Tensor) – (b x m) Level-set posterior given observation of 1

  • P0 (torch.Tensor) – (b x m) Level-set posterior given observation of 0

  • py1 (torch.Tensor) – (b x 1) Probability of observing 1

Return type:

Tensor

Returns: (b) torch.tensor of mutual information averaged over Xq.

aepsych.acquisition.lookahead.ClassErr(p)[source]

Expected classification error, min(p, 1-p).

Parameters:

p (torch.Tensor) – torch.Tensor of predicted probabilities.

Returns:

Expected classification error for each probability, computed as min(p, 1 - p).

Return type:

torch.Tensor

aepsych.acquisition.lookahead.SUR_fn(Px, P1, P0, py1)[source]

Stepwise uncertainty reduction.

Expected reduction in expected classification error given observation at Xstar, averaged over Xq.

Parameters:
  • Px (torch.Tensor) – (b x m) Level-set posterior before observation

  • P1 (torch.Tensor) – (b x m) Level-set posterior given observation of 1

  • P0 (torch.Tensor) – (b x m) Level-set posterior given observation of 0

  • py1 (torch.Tensor) – (b x 1) Probability of observing 1

Returns:

  1. torch.Tensor of SUR values.

Return type:

Tensor

aepsych.acquisition.lookahead.EAVC_fn(Px, P1, P0, py1)[source]

Expected absolute value change.

Expected absolute change in expected level-set volume given observation at Xstar.

Parameters:
  • Px (torch.Tensor) – (b x m) Level-set posterior before observation

  • P1 (torch.Tensor) – (b x m) Level-set posterior given observation of 1

  • P0 (torch.Tensor) – (b x m) Level-set posterior given observation of 0

  • py1 (torch.Tensor) – (b x 1) Probability of observing 1

Returns:

  1. torch.Tensor of EAVC values.

Return type:

Tensor

class aepsych.acquisition.lookahead.LookaheadAcquisitionFunction(*args, **kwargs)[source]

Bases: AcquisitionFunction

A localized look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • target (float, optional) – Threshold value to target in p-space.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

class aepsych.acquisition.lookahead.LocalLookaheadAcquisitionFunction(*args, **kwargs)[source]

Bases: LookaheadAcquisitionFunction

A localized look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

forward(X)

Evaluate acquisition function at X.

Parameters:

X (torch.Tensor) – (b x 1 x d) point at which to evalaute acquisition function.

Returns:

  1. torch.Tensor of acquisition values.

Return type:

Tensor

class aepsych.acquisition.lookahead.LocalMI(*args, **kwargs)[source]

Bases: LocalLookaheadAcquisitionFunction

A localized look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.lookahead.LocalSUR(*args, **kwargs)[source]

Bases: LocalLookaheadAcquisitionFunction

A localized look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

aepsych.acquisition.lookahead.construct_inputs_local_lookahead(model, training_data, lookahead_type='levelset', target=None, posterior_transform=None, **kwargs)

Constructs the input dictionary for initializing local lookahead acquisition functions.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • training_data (None) – Placeholder for compatibility; not used in this function.

  • lookahead_type (Literal["levelset", "posterior"]) – Type of look-ahead to perform. Default is “levelset”. - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Target threshold value in probability space. Default is None.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default is None.

Returns:

Dictionary of constructed inputs for local lookahead acquisition functions.

Return type:

Dict[str, Any]

class aepsych.acquisition.lookahead.GlobalLookaheadAcquisitionFunction(*args, **kwargs)[source]

Bases: LookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

forward(X)

Evaluate acquisition function at X.

Parameters:

X (torch.Tensor) – (b x 1 x d) point at which to evalaute acquisition function.

Returns:

  1. torch.Tensor of acquisition values.

Return type:

Tensor

class aepsych.acquisition.lookahead.GlobalMI(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.lookahead.GlobalSUR(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.lookahead.ApproxGlobalSUR(*args, **kwargs)[source]

Bases: GlobalSUR

An approximate global look-ahead acquisition function. :param model: The gpytorch model to use. :type model: GPyTorchModel :param lookahed_type: The type of look-ahead to perform (default is “levelset”). :type lookahed_type: str :param target: Threshold value to target in p-space. :type target: float, optional :param query_set_size: Number of points in the query set. :type query_set_size: int, optional :param Xq: (m x d) global reference set. :type Xq: torch.Tensor, optional

Parameters:
  • model (botorch.models.gpytorch.GPyTorchModel) –

  • target (Optional[float]) –

  • query_set_size (Optional[int]) –

  • Xq (Optional[Tensor]) –

class aepsych.acquisition.lookahead.EAVC(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.lookahead.MOCU(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

MOCU acquisition function given in expr. 4 of:

Zhao, Guang, et al. “Uncertainty-aware active learning for optimal Bayesian classifier.” International Conference on Learning Representations (ICLR) 2021.

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.lookahead.SMOCU(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

SMOCU acquisition function given in expr. 11 of:

Zhao, Guang, et al. “Bayesian active learning by soft mean objective cost of uncertainty.” International Conference on Artificial Intelligence and Statistics (AISTATS) 2021.

model (GPyTorchModel): The gpytorch model to use. lookahead_type (str): The type of look-ahead to perform (default is “posterior”). target (float, optional): Threshold value to target in p-space. Default is None. query_set_size (int, optional): Number of points in the query set. Default is 256. Xq (torch.Tensor, optional): (m x d) global reference set. Default is None. k (float, optional): Scaling factor for the softmax approximation, controlling the “softness” of the maximum operation. Default is 20.0.

Parameters:
  • model (botorch.models.gpytorch.GPyTorchModel) –

  • target (Optional[float]) –

  • query_set_size (Optional[int]) –

  • Xq (Optional[Tensor]) –

  • k (Optional[float]) –

class aepsych.acquisition.lookahead.BEMPS(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

BEMPS acquisition function given in:

Tan, Wei, et al. “Diversity Enhanced Active Learning with Strictly Proper Scoring Rules.” Advances in Neural Information Processing Systems 34 (2021).

scorefun (Callable): Scoring function to use for the BEMPS acquisition function.

Parameters:

scorefun (Callable) –

aepsych.acquisition.lookahead.construct_inputs_global_lookahead(model, training_data, lookahead_type='levelset', target=None, posterior_transform=None, query_set_size=256, Xq=None, **kwargs)

Constructs the input dictionary for initializing global lookahead acquisition functions.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • training_data (None) – Placeholder for compatibility; not used in this function.

  • lookahead_type (str) – Type of look-ahead to perform. Default is “levelset”.

  • target (float, optional) – Target threshold value in probability space. Default is None.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default is None.

  • query_set_size (int, optional) – Number of points in the query set. Default is 256.

  • Xq (torch.Tensor, optional) – (m x d) global reference set. If not provided, a Sobol sequence is generated. Default is None.

Returns:

Dictionary of constructed inputs for global lookahead acquisition functions.

Return type:

Dict[str, Any]

aepsych.acquisition.lookahead_utils module

aepsych.acquisition.lookahead_utils.posterior_at_xstar_xq(model, Xstar, Xq, posterior_transform=None)[source]

Evaluate the posteriors of f at single point Xstar and set of points Xq.

Parameters:
  • model (GP) – The model to evaluate.

  • Xstar (torch.Tensor) – (b x 1 x d) observation point.

  • Xq (torch.Tensor) – (b x m x d) reference points.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

Returns:

Tuple of the following:
  • Mu_s: (b x 1) mean at Xstar.

  • Sigma2_s: (b x 1) variance at Xstar.

  • Mu_q: (b x m) mean at Xq.

  • Sigma2_q: (b x m) variance at Xq.

  • Sigma_sq: (b x m) covariance between Xstar and each point in Xq.

Return type:

Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

aepsych.acquisition.lookahead_utils.lookahead_levelset_at_xstar(model, Xstar, Xq, posterior_transform=None, eps=1e-08, **kwargs)[source]

Evaluate the look-ahead level-set posterior at Xq given observation at xstar.

Parameters:
  • model (GP) – The model to evaluate.

  • Xstar (torch.Tensor) – (b x 1 x d) observation point.

  • Xq (torch.Tensor) – (b x m x d) reference points.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

  • eps (float) – Small value to avoid division by zero. Default: 1e-8.

  • kwargs (Dict[str, Any]) –

Returns:

Tuple of the following:

Px: (b x m) Level-set posterior at Xq, before observation at xstar. P1: (b x m) Level-set posterior at Xq, given observation of 1 at xstar. P0: (b x m) Level-set posterior at Xq, given observation of 0 at xstar. py1: (b x 1) Probability of observing 1 at xstar.

Return type:

Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

aepsych.acquisition.lookahead_utils.lookahead_p_at_xstar(model, Xstar, Xq, posterior_transform=None, **kwargs)[source]

Evaluate the look-ahead response probability posterior at Xq given observation at xstar.

Uses the approximation given in expr. 9 in: Zhao, Guang, et al. “Efficient active learning for Gaussian process classification by error reduction.” Advances in Neural Information Processing Systems 34 (2021): 9734-9746.

Parameters:
  • model (GP) – The model to evaluate.

  • Xstar (torch.Tensor) – (b x 1 x d) observation point.

  • Xq (torch.Tensor) – (b x m x d) reference points.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

  • kwargs (Dict[str, Any]) – ignored (here for compatibility with other kinds of lookahead)

Returns:

Tuple of the following:
  • Px: (b x m) Response posterior at Xq, before observation at xstar.

  • P1: (b x m) Response posterior at Xq, given observation of 1 at xstar.

  • P0: (b x m) Response posterior at Xq, given observation of 0 at xstar.

  • py1: (b x 1) Probability of observing 1 at xstar.

Return type:

Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

aepsych.acquisition.lookahead_utils.approximate_lookahead_levelset_at_xstar(model, Xstar, Xq, gamma, posterior_transform=None)[source]

The look-ahead posterior approximation of Lyu et al.

Parameters:
  • model (GP) – The model to evaluate.

  • Xstar (torch.Tensor) – (b x 1 x d) observation point.

  • Xq (torch.Tensor) – (b x m x d) reference points.

  • gamma (float) – The threshold value.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

Returns:

Tuple of the following:
  • Px: (b x m) Level-set posterior at Xq, before observation at xstar.

  • P1: (b x m) Level-set posterior at Xq, given observation of 1 at xstar.

  • P0: (b x m) Level-set posterior at Xq, given observation of 0 at xstar.

  • py1: (b x 1) Probability of observing 1 at xstar.

Return type:

Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

aepsych.acquisition.lse module

class aepsych.acquisition.lse.MCLevelSetEstimation(*args, **kwargs)[source]

Bases: MCAcquisitionFunction

Monte-carlo level set estimation.

Parameters:
  • model (botorch.models.model.Model) – A fitted model.

  • target (Union[float, Tensor]) – the level set (after objective transform) to be estimated. Defult to 0.75.

  • beta (Union[float, Tensor]) – a parameter that governs explore-exploit tradeoff. Defult to 3.84.

  • objective (MCAcquisitionObjective, optional) – An MCAcquisitionObjective representing the link function (e.g., logistic or probit.) applied on the samples. Can be implemented via GenericMCObjective.

  • sampler (MCSampler, optional) – The sampler used for drawing MC samples.

acquisition(obj_samples)[source]

Evaluate the acquisition based on objective samples.

Usually you should not call this directly unless you are subclassing this class and modifying how objective samples are generated.

Parameters:

obj_samples (torch.Tensor) – Samples from the model, transformed by the objective. Should be samples x batch_shape.

Returns:

Acquisition function at the sampled values.

Return type:

torch.Tensor

forward(X)

Evaluate the acquisition function

Parameters:

X (torch.Tensor) – Points at which to evaluate.

Returns:

Value of the acquisition functiona at these points.

Return type:

torch.Tensor

aepsych.acquisition.lse.construct_inputs_lse(model, training_data, objective=None, target=0.75, beta=3.84, sampler=None, **kwargs)

Constructs the input dictionary for initializing the MCLevelSetEstimation acquisition function.

Parameters:
  • model (Model) – The fitted model to be used.

  • training_data (None) – Placeholder for compatibility; not used in this function.

  • objective (MCAcquisitionObjective, optional) – Objective function for transforming samples (e.g., logistic or probit).

  • target (Union[float, Tensor]) – Level set to be estimated, defaulting to 0.75.

  • beta (Union[float, Tensor]) – Parameter controlling explore-exploit tradeoff, default is 3.84.

  • sampler (MCSampler, optional) – Sampler for Monte Carlo sampling; defaults to SobolQMCNormalSampler if not provided.

Returns:

Dictionary of constructed inputs for the MCLevelSetEstimation acquisition function.

Return type:

Dict[str, Any]

aepsych.acquisition.mc_posterior_variance module

aepsych.acquisition.mc_posterior_variance.balv_acq(obj_samps)[source]

Evaluate BALV (posterior variance) on a set of objective samples.

Parameters:

obj_samps (torch.Tensor) – Samples from the GP, transformed by the objective. Should be samples x batch_shape.

Returns:

Acquisition function value.

Return type:

torch.Tensor

class aepsych.acquisition.mc_posterior_variance.MCPosteriorVariance(*args, **kwargs)[source]

Bases: MCAcquisitionFunction

Posterior variance, computed using samples so we can use objective/transform

Posterior Variance of Link Function

Parameters:
  • model (Model) – A fitted model.

  • objective (MCAcquisitionObjective optional) – An MCAcquisitionObjective representing the link function (e.g., logistic or probit.) applied on the difference of (usually 1-d) two samples. Can be implemented via GenericMCObjective. Defaults tp ProbitObjective.

  • sampler (MCSampler, optional) – The sampler used for drawing MC samples. Defaults to SobolQMCNormalSampler.

forward(X)

Evaluate MCPosteriorVariance on the candidate set X.

Parameters:

X (torch.Tensor) – A batch_size x q x d-dim Tensor

Returns:

Posterior variance of link function at X that active learning hopes to maximize

Return type:

torch.Tensor

acquisition(obj_samples)[source]

Evaluate the acquisition based on objective samples.

Parameters:

obj_samples (torch.Tensor) – Samples from the GP, transformed by the objective. Should be samples x batch_shape.

Returns:

Acquisition function at the sampled values.

Return type:

torch.Tensor

aepsych.acquisition.mc_posterior_variance.construct_inputs(model, training_data, objective=None, sampler=None, **kwargs)

Constructs the input dictionary for initializing the MCPosteriorVariance acquisition function.

Parameters:
  • model (Model) – The fitted model to be used.

  • training_data (None) – Placeholder for compatibility; not used in this function.

  • objective (MCAcquisitionObjective, optional) – Objective function for transforming samples (e.g., logistic or probit).

  • sampler (MCSampler, optional) – Sampler for Monte Carlo sampling; defaults to SobolQMCNormalSampler if not provided.

Returns:

Dictionary of constructed inputs for the MCPosteriorVariance acquisition function.

Return type:

Dict[str, Any]

class aepsych.acquisition.mc_posterior_variance.MonotonicMCPosteriorVariance(*args, **kwargs)[source]

Bases: MonotonicMCAcquisition

Initialize MonotonicMCAcquisition

Parameters:
  • model (Model) – Model to use, usually a MonotonicRejectionGP.

  • num_samples (int) – Number of samples to keep from the rejection sampler. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples to draw. Defaults to 1024.

  • objective (MCAcquisitionObjective, optional) – Objective transform of the GP output before evaluating the acquisition. Defaults to identity transform.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

acquisition(obj_samples)[source]

Evaluates the acquisition function value for monotonic posterior variance.

Parameters:

obj_samples (torch.Tensor) – Samples from the GP, transformed by the objective. Should have shape samples x batch_shape.

Returns:

The BALV acquisition function value, representing the posterior variance calculated over the sample dimension.

Return type:

torch.Tensor

aepsych.acquisition.monotonic_rejection module

class aepsych.acquisition.monotonic_rejection.MonotonicMCAcquisition(*args, **kwargs)[source]

Bases: AcquisitionFunction

Acquisition function base class for use with the rejection sampling

monotonic GP. This handles the bookkeeping of the derivative constraint points – implement specific monotonic MC acquisition in subclasses.

Initialize MonotonicMCAcquisition

Parameters:
  • model (Model) – Model to use, usually a MonotonicRejectionGP.

  • num_samples (int) – Number of samples to keep from the rejection sampler. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples to draw. Defaults to 1024.

  • objective (MCAcquisitionObjective, optional) – Objective transform of the GP output before evaluating the acquisition. Defaults to identity transform.

  • deriv_constraint_points (torch.Tensor) –

forward(X)[source]

Evaluate the acquisition function at a set of points.

Parameters:

X (torch.Tensor) – Points at which to evaluate the acquisition function. Should be (b) x q x d, and q should be 1.

Returns:

Acquisition function value at these points.

Return type:

torch.Tensor

acquisition(obj_samples)[source]
Parameters:

obj_samples (Tensor) –

Return type:

Tensor

class aepsych.acquisition.monotonic_rejection.MonotonicMCLSE(*args, **kwargs)[source]

Bases: MonotonicMCAcquisition

Level set estimation acquisition function for use with monotonic models.

Parameters:
  • model (Model) – Underlying model object, usually should be MonotonicRejectionGP.

  • deriv_constraint_points (torch.Tensor) – Points at which the derivative should be constrained.

  • target (float) – Level set value to target (after the objective).

  • num_samples (int) – Number of MC samples to draw in MC acquisition. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples from which to subsample monotonic ones. Defaults to 1024.

  • beta (float) – Parameter of the LSE acquisition function that governs exploration vs exploitation (similarly to the same parameter in UCB). Defaults to 3.84 (1.96 ** 2), which maps to the straddle heuristic of Bryan et al. 2005.

  • objective (MCAcquisitionObjective, optional) – Objective transform. Defaults to identity transform.

acquisition(obj_samples)[source]

Computes the acquisition function value for level set estimation in monotonic models.

Parameters:

obj_samples (torch.Tensor) – Tensor of samples from the model, transformed by the objective. Expected shape is samples x batch_shape.

Returns:

The acquisition function value, calculated as the difference between an exploration-exploitation term (based on the variance and beta parameter) and the absolute difference between the mean and the target level set.

Return type:

torch.Tensor

aepsych.acquisition.mutual_information module

aepsych.acquisition.mutual_information.bald_acq(obj_samples)[source]

Evaluate Mutual Information acquisition function.

With latent function F and X a hypothetical observation at a new point, I(F; X) = I(X; F) = H(X) - H(X |F), H(X |F ) = E_{f} (H(X |F =f ) i.e., we take the posterior entropy of the (Bernoulli) observation X given the current model posterior and subtract the conditional entropy on F, that being the mean entropy over the posterior for F. This is equivalent to the BALD acquisition function in Houlsby et al. NeurIPS 2012.

Parameters:

obj_samples (torch.Tensor) – Objective samples from the GP, of shape num_samples x batch_shape x d_out

Returns:

Value of acquisition at samples.

Return type:

torch.Tensor

class aepsych.acquisition.mutual_information.BernoulliMCMutualInformation(*args, **kwargs)[source]

Bases: MCAcquisitionFunction

Mutual Information acquisition function for a bernoulli outcome.

Given a model and an objective link function, calculate the mutual information of a trial at a new point and the distribution on the latent function.

Objective here should give values in (0, 1) (e.g. logit or probit).

Single Bernoulli mutual information for active learning

Parameters:
  • model (Model) – A fitted model.

  • objective (MCAcquisitionObjective) – An MCAcquisitionObjective representing the link function (e.g., logistic or probit)

  • sampler (MCSampler, optional) – The sampler used for drawing MC samples.

forward(X)

Evaluate mutual information on the candidate set X.

Parameters:

X (Tensor) – A batch_size x q x d-dim Tensor.

Returns:

Tensor of shape batch_size x q representing the mutual information of a hypothetical trial at X that active learning hopes to maximize.

Return type:

Tensor

acquisition(obj_samples)[source]

Evaluate the acquisition function value based on samples.

Parameters:

obj_samples (torch.Tensor) – Samples from the model, transformed through the objective.

Returns:

value of the acquisition function (BALD) at the input samples.

Return type:

torch.Tensor

aepsych.acquisition.mutual_information.construct_inputs_mi(model, training_data, objective=None, sampler=None, **kwargs)

Constructs the input dictionary for initializing the BernoulliMCMutualInformation acquisition function.

Parameters:
  • model (Model) – The fitted model to use.

  • training_data (None) – Placeholder for compatibility; not used in this function.

  • objective (MCAcquisitionObjective, optional) – Objective function for transforming samples (e.g., logit or probit).

  • sampler (MCSampler, optional) – Sampler for Monte Carlo sampling; defaults to SobolQMCNormalSampler if not provided.

Returns:

Dictionary of constructed inputs for the BernoulliMCMutualInformation acquisition function.

Return type:

Dict[str, Any]

class aepsych.acquisition.mutual_information.MonotonicBernoulliMCMutualInformation(*args, **kwargs)[source]

Bases: MonotonicMCAcquisition

Initialize MonotonicMCAcquisition

Parameters:
  • model (Model) – Model to use, usually a MonotonicRejectionGP.

  • num_samples (int) – Number of samples to keep from the rejection sampler. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples to draw. Defaults to 1024.

  • objective (MCAcquisitionObjective, optional) – Objective transform of the GP output before evaluating the acquisition. Defaults to identity transform.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

acquisition(obj_samples)[source]

Evaluate the acquisition function value based on samples.

Parameters:

obj_samples (torch.Tensor) – Samples from the model, transformed through the objective.

Returns:

value of the acquisition function (BALD) at the input samples.

Return type:

torch.Tensor

aepsych.acquisition.objective module

class aepsych.acquisition.objective.AEPsychObjective(*args, **kwargs)[source]

Bases: MCAcquisitionObjective

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

inverse(samples, X=None)[source]
Parameters:
  • samples (Tensor) –

  • X (Optional[Tensor]) –

Return type:

Tensor

class aepsych.acquisition.objective.FloorGumbelObjective(*args, **kwargs)[source]

Bases: FloorLinkObjective

Gumbel CDF but with a floor so that its output is between floor and 1.0. Note that this is not the standard Gumbel distribution, but rather the left-skewed Gumbel that arises as the log of the Weibull distribution, e.g. Treutwein 1995, doi:10.1016/0042-6989(95)00016-X.

Initialize the objective with a floor value.

Parameters:
  • floor (float) – The floor value. Defaults to 0.5.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

Evaluates the link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

Transformed tensor with the link function applied, where positive infinity values are replaced with 1.0 and negative infinity values are replaced with 0.0.

Return type:

Tensor

Evaluates the inverse link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

The logarithm of the inverse link function applied to the input samples.

Return type:

Tensor

class aepsych.acquisition.objective.FloorLogitObjective(*args, **kwargs)[source]

Bases: FloorLinkObjective

Logistic sigmoid (aka expit, aka logistic CDF), but with a floor so that its output is between floor and 1.0.

Initialize the objective with a floor value.

Parameters:
  • floor (float) – The floor value. Defaults to 0.5.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

Evaluates the link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

The Expit function applied to the input samples.

Return type:

Tensor

Evaluates the inverse link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

The logarithm of the inverse link function applied to the input samples.

Return type:

Tensor

class aepsych.acquisition.objective.FloorProbitObjective(*args, **kwargs)[source]

Bases: FloorLinkObjective

Probit (aka Gaussian CDF), but with a floor so that its output is between floor and 1.0.

Initialize the objective with a floor value.

Parameters:
  • floor (float) – The floor value. Defaults to 0.5.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

Evaluates the link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

the cumulative distribution function of the standard normal distribution of the input samples.

Return type:

Tensor

Evaluates the inverse link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

the inverse cumulative distribution function of the standard normal distribution of the input samples.

Return type:

Tensor

class aepsych.acquisition.objective.ProbitObjective(*args, **kwargs)[source]

Bases: AEPsychObjective

Probit objective

Transforms the input through the normal CDF (probit).

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

forward(samples, X=None)[source]

Evaluates the objective (normal CDF).

Parameters:
  • samples (Tensor) – GP samples.

  • X (Tensor, optional) – ignored, here for compatibility with MCAcquisitionObjective.

Returns:

[description]

Return type:

Tensor

inverse(samples, X=None)[source]

Evaluates the inverse of the objective (normal PPF).

Parameters:
  • samples (Tensor) – GP samples.

  • X (Tensor, optional) – ignored, here for compatibility with MCAcquisitionObjective.

Returns:

[description]

Return type:

Tensor

class aepsych.acquisition.objective.SemiPProbabilityObjective(*args, **kwargs)[source]

Bases: SemiPObjectiveBase

Wraps the semi-parametric transform into an objective that gives outcome probabilities

Evaluates the probability objective.

Parameters:
  • likelihood (Likelihood). Underlying SemiP likelihood (which we use for its objective/link) –

  • class (other arguments are passed to the base) –

forward(samples, X)[source]

Evaluates the probability objective.

Parameters:
  • samples (Tensor) – GP samples.

  • X (Tensor) – Inputs at which to evaluate objective. Unlike most AEPsych objectives, we need X here to split out the intensity dimension.

Returns:

Response probabilities at the specific X values and function samples.

Return type:

Tensor

classmethod from_config(config)[source]

Create a SemiPProbabilityObjective from a config object.

Parameters:

config (Config) – Configuration object containing the initialization parameters.

Returns:

A SemiPProbabilityObjective object.

Return type:

SemiPProbabilityObjective

class aepsych.acquisition.objective.SemiPThresholdObjective(*args, **kwargs)[source]

Bases: SemiPObjectiveBase

Wraps the semi-parametric transform into an objective that gives the threshold distribution.

Evaluates the probability objective.

Parameters:
  • target (float) – the threshold to evaluate.

  • likelihood (LinearBernoulliLikelihood, optional) – Underlying SemiP likelihood (which we use for its inverse link). Defaults to None.

  • class (other arguments are passed to the base) –

forward(samples, X=None)[source]

Evaluates the probability objective.

Parameters:
  • samples (Tensor) – GP samples.

  • X (Tensor, optional) – Ignored, here for compatibility with the objective API.

Returns:

Threshold probabilities at the specific GP sample values.

Return type:

Tensor

classmethod from_config(config)[source]

Create a SemiPThresholdObjective from a config object.

Parameters:

config (Config) – Configuration object containing the initialization parameters.

Returns:

A SemiPThresholdObjective object.

Return type:

SemiPThresholdObjective

aepsych.acquisition.rejection_sampler module

class aepsych.acquisition.rejection_sampler.RejectionSampler(*args, **kwargs)[source]

Bases: MCSampler

Samples from a posterior subject to the constraint that samples in constrained_idx should be >= 0.

If not enough feasible samples are generated, will return the least violating samples.

Initialize RejectionSampler

Parameters:
  • num_samples (int) – Number of samples to return. Note that if fewer samples than this number are positive in the required dimension, the remaining samples returned will be the “least violating”, i.e. closest to 0.

  • num_rejection_samples (int) – Number of samples to draw before rejecting.

  • constrained_idx (torch.Tensor) – Indices of input dimensions that should be constrained positive.

forward(posterior)[source]

Run the rejection sampler.

Parameters:

posterior (Posterior) – The unconstrained GP posterior object to perform rejection samples on.

Returns:

Kept samples.

Return type:

torch.Tensor

Module contents

class aepsych.acquisition.BernoulliMCMutualInformation(*args, **kwargs)[source]

Bases: MCAcquisitionFunction

Mutual Information acquisition function for a bernoulli outcome.

Given a model and an objective link function, calculate the mutual information of a trial at a new point and the distribution on the latent function.

Objective here should give values in (0, 1) (e.g. logit or probit).

Single Bernoulli mutual information for active learning

Parameters:
  • model (Model) – A fitted model.

  • objective (MCAcquisitionObjective) – An MCAcquisitionObjective representing the link function (e.g., logistic or probit)

  • sampler (MCSampler, optional) – The sampler used for drawing MC samples.

forward(X)

Evaluate mutual information on the candidate set X.

Parameters:

X (Tensor) – A batch_size x q x d-dim Tensor.

Returns:

Tensor of shape batch_size x q representing the mutual information of a hypothetical trial at X that active learning hopes to maximize.

Return type:

Tensor

acquisition(obj_samples)[source]

Evaluate the acquisition function value based on samples.

Parameters:

obj_samples (torch.Tensor) – Samples from the model, transformed through the objective.

Returns:

value of the acquisition function (BALD) at the input samples.

Return type:

torch.Tensor

class aepsych.acquisition.MonotonicBernoulliMCMutualInformation(*args, **kwargs)[source]

Bases: MonotonicMCAcquisition

Initialize MonotonicMCAcquisition

Parameters:
  • model (Model) – Model to use, usually a MonotonicRejectionGP.

  • num_samples (int) – Number of samples to keep from the rejection sampler. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples to draw. Defaults to 1024.

  • objective (MCAcquisitionObjective, optional) – Objective transform of the GP output before evaluating the acquisition. Defaults to identity transform.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

acquisition(obj_samples)[source]

Evaluate the acquisition function value based on samples.

Parameters:

obj_samples (torch.Tensor) – Samples from the model, transformed through the objective.

Returns:

value of the acquisition function (BALD) at the input samples.

Return type:

torch.Tensor

class aepsych.acquisition.MonotonicMCLSE(*args, **kwargs)[source]

Bases: MonotonicMCAcquisition

Level set estimation acquisition function for use with monotonic models.

Parameters:
  • model (Model) – Underlying model object, usually should be MonotonicRejectionGP.

  • deriv_constraint_points (torch.Tensor) – Points at which the derivative should be constrained.

  • target (float) – Level set value to target (after the objective).

  • num_samples (int) – Number of MC samples to draw in MC acquisition. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples from which to subsample monotonic ones. Defaults to 1024.

  • beta (float) – Parameter of the LSE acquisition function that governs exploration vs exploitation (similarly to the same parameter in UCB). Defaults to 3.84 (1.96 ** 2), which maps to the straddle heuristic of Bryan et al. 2005.

  • objective (MCAcquisitionObjective, optional) – Objective transform. Defaults to identity transform.

acquisition(obj_samples)[source]

Computes the acquisition function value for level set estimation in monotonic models.

Parameters:

obj_samples (torch.Tensor) – Tensor of samples from the model, transformed by the objective. Expected shape is samples x batch_shape.

Returns:

The acquisition function value, calculated as the difference between an exploration-exploitation term (based on the variance and beta parameter) and the absolute difference between the mean and the target level set.

Return type:

torch.Tensor

class aepsych.acquisition.MCPosteriorVariance(*args, **kwargs)[source]

Bases: MCAcquisitionFunction

Posterior variance, computed using samples so we can use objective/transform

Posterior Variance of Link Function

Parameters:
  • model (Model) – A fitted model.

  • objective (MCAcquisitionObjective optional) – An MCAcquisitionObjective representing the link function (e.g., logistic or probit.) applied on the difference of (usually 1-d) two samples. Can be implemented via GenericMCObjective. Defaults tp ProbitObjective.

  • sampler (MCSampler, optional) – The sampler used for drawing MC samples. Defaults to SobolQMCNormalSampler.

forward(X)

Evaluate MCPosteriorVariance on the candidate set X.

Parameters:

X (torch.Tensor) – A batch_size x q x d-dim Tensor

Returns:

Posterior variance of link function at X that active learning hopes to maximize

Return type:

torch.Tensor

acquisition(obj_samples)[source]

Evaluate the acquisition based on objective samples.

Parameters:

obj_samples (torch.Tensor) – Samples from the GP, transformed by the objective. Should be samples x batch_shape.

Returns:

Acquisition function at the sampled values.

Return type:

torch.Tensor

class aepsych.acquisition.MonotonicMCPosteriorVariance(*args, **kwargs)[source]

Bases: MonotonicMCAcquisition

Initialize MonotonicMCAcquisition

Parameters:
  • model (Model) – Model to use, usually a MonotonicRejectionGP.

  • num_samples (int) – Number of samples to keep from the rejection sampler. Defaults to 32.

  • num_rejection_samples (int) – Number of rejection samples to draw. Defaults to 1024.

  • objective (MCAcquisitionObjective, optional) – Objective transform of the GP output before evaluating the acquisition. Defaults to identity transform.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

acquisition(obj_samples)[source]

Evaluates the acquisition function value for monotonic posterior variance.

Parameters:

obj_samples (torch.Tensor) – Samples from the GP, transformed by the objective. Should have shape samples x batch_shape.

Returns:

The BALV acquisition function value, representing the posterior variance calculated over the sample dimension.

Return type:

torch.Tensor

class aepsych.acquisition.MCLevelSetEstimation(*args, **kwargs)[source]

Bases: MCAcquisitionFunction

Monte-carlo level set estimation.

Parameters:
  • model (botorch.models.model.Model) – A fitted model.

  • target (Union[float, Tensor]) – the level set (after objective transform) to be estimated. Defult to 0.75.

  • beta (Union[float, Tensor]) – a parameter that governs explore-exploit tradeoff. Defult to 3.84.

  • objective (MCAcquisitionObjective, optional) – An MCAcquisitionObjective representing the link function (e.g., logistic or probit.) applied on the samples. Can be implemented via GenericMCObjective.

  • sampler (MCSampler, optional) – The sampler used for drawing MC samples.

acquisition(obj_samples)[source]

Evaluate the acquisition based on objective samples.

Usually you should not call this directly unless you are subclassing this class and modifying how objective samples are generated.

Parameters:

obj_samples (torch.Tensor) – Samples from the model, transformed by the objective. Should be samples x batch_shape.

Returns:

Acquisition function at the sampled values.

Return type:

torch.Tensor

forward(X)

Evaluate the acquisition function

Parameters:

X (torch.Tensor) – Points at which to evaluate.

Returns:

Value of the acquisition functiona at these points.

Return type:

torch.Tensor

class aepsych.acquisition.ProbitObjective(*args, **kwargs)[source]

Bases: AEPsychObjective

Probit objective

Transforms the input through the normal CDF (probit).

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

forward(samples, X=None)[source]

Evaluates the objective (normal CDF).

Parameters:
  • samples (Tensor) – GP samples.

  • X (Tensor, optional) – ignored, here for compatibility with MCAcquisitionObjective.

Returns:

[description]

Return type:

Tensor

inverse(samples, X=None)[source]

Evaluates the inverse of the objective (normal PPF).

Parameters:
  • samples (Tensor) – GP samples.

  • X (Tensor, optional) – ignored, here for compatibility with MCAcquisitionObjective.

Returns:

[description]

Return type:

Tensor

class aepsych.acquisition.FloorProbitObjective(*args, **kwargs)[source]

Bases: FloorLinkObjective

Probit (aka Gaussian CDF), but with a floor so that its output is between floor and 1.0.

Initialize the objective with a floor value.

Parameters:
  • floor (float) – The floor value. Defaults to 0.5.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

Evaluates the link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

the cumulative distribution function of the standard normal distribution of the input samples.

Return type:

Tensor

Evaluates the inverse link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

the inverse cumulative distribution function of the standard normal distribution of the input samples.

Return type:

Tensor

class aepsych.acquisition.FloorLogitObjective(*args, **kwargs)[source]

Bases: FloorLinkObjective

Logistic sigmoid (aka expit, aka logistic CDF), but with a floor so that its output is between floor and 1.0.

Initialize the objective with a floor value.

Parameters:
  • floor (float) – The floor value. Defaults to 0.5.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

Evaluates the link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

The Expit function applied to the input samples.

Return type:

Tensor

Evaluates the inverse link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

The logarithm of the inverse link function applied to the input samples.

Return type:

Tensor

class aepsych.acquisition.FloorGumbelObjective(*args, **kwargs)[source]

Bases: FloorLinkObjective

Gumbel CDF but with a floor so that its output is between floor and 1.0. Note that this is not the standard Gumbel distribution, but rather the left-skewed Gumbel that arises as the log of the Weibull distribution, e.g. Treutwein 1995, doi:10.1016/0042-6989(95)00016-X.

Initialize the objective with a floor value.

Parameters:
  • floor (float) – The floor value. Defaults to 0.5.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

Evaluates the link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

Transformed tensor with the link function applied, where positive infinity values are replaced with 1.0 and negative infinity values are replaced with 0.0.

Return type:

Tensor

Evaluates the inverse link function for input x and floor f

Parameters:

samples (Tensor) – GP samples.

Returns:

The logarithm of the inverse link function applied to the input samples.

Return type:

Tensor

class aepsych.acquisition.GlobalMI(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.GlobalSUR(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.ApproxGlobalSUR(*args, **kwargs)[source]

Bases: GlobalSUR

An approximate global look-ahead acquisition function. :param model: The gpytorch model to use. :type model: GPyTorchModel :param lookahed_type: The type of look-ahead to perform (default is “levelset”). :type lookahed_type: str :param target: Threshold value to target in p-space. :type target: float, optional :param query_set_size: Number of points in the query set. :type query_set_size: int, optional :param Xq: (m x d) global reference set. :type Xq: torch.Tensor, optional

Parameters:
  • model (botorch.models.gpytorch.GPyTorchModel) –

  • target (Optional[float]) –

  • query_set_size (Optional[int]) –

  • Xq (Optional[Tensor]) –

class aepsych.acquisition.EAVC(*args, **kwargs)[source]

Bases: GlobalLookaheadAcquisitionFunction

A global look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior.

  • query_set_size (int, optional) – Number of points in the query set.

  • Xq (torch.Tensor, optional) – (m x d) global reference set.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.LocalMI(*args, **kwargs)[source]

Bases: LocalLookaheadAcquisitionFunction

A localized look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any

class aepsych.acquisition.LocalSUR(*args, **kwargs)[source]

Bases: LocalLookaheadAcquisitionFunction

A localized look-ahead acquisition function.

Parameters:
  • model (GPyTorchModel) – The gpytorch model to use.

  • lookahead_type (Literal["levelset", "posterior"]) – The type of look-ahead to perform (default is “levelset”). - If the lookahead_type is “levelset”, the acqf will consider the posterior probability that a point is above or below the target level set. - If the lookahead_type is “posterior”, the acqf will consider the posterior probability that a point will be detected or not.

  • target (float, optional) – Threshold value to target in p-space.

  • posterior_transform (PosteriorTransform, optional) – Optional transformation to apply to the posterior. Default: None.

  • args (Any) –

  • kwargs (Any) –

Return type:

Any