aepsych.likelihoods

aepsych.likelihoods module

class aepsych.likelihoods.BernoulliObjectiveLikelihood(objective)[source]

Bases: _OneDimensionalLikelihood

Bernoulli likelihood with a flexible link (objective) defined by a callable (which can be a botorch objective)

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Parameters:

objective (Callable) –

forward(function_samples, **kwargs)[source]

Computes the conditional distribution \(p(\mathbf y \mid \mathbf f, \ldots)\) that defines the likelihood.

Parameters:
  • function_samples – Samples from the function (\(\mathbf f\))

  • data – (Pyro integration only.) Additional variables that the likelihood needs to condition on. The keys of the dictionary will correspond to Pyro sample sites in the likelihood’s model/guide.

  • args – Additional args

  • kwargs – Additional kwargs

classmethod from_config(config)[source]
Parameters:

config (Config) –

class aepsych.likelihoods.OrdinalLikelihood(n_levels, link=None)[source]

Bases: Likelihood

Ordinal likelihood, suitable for rating models (e.g. likert scales). Formally, .. math:: z_k(xmid f) := p(d_k < f(x) le d_{k+1}) = sigma(d_{k+1}-f(x)) - sigma(d_{k}-f(x)), where \(\sigma()\) is the link function (equivalent to the perceptual noise distribution in psychophysics terms), \(f(x)\) is the latent GP evaluated at x, and \(d_k\) is a learned cutpoint parameter for each level.

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Parameters:
  • n_levels (int) –

  • link (Optional[Callable]) –

property cutpoints
forward(function_samples, *params, **kwargs)[source]

Computes the conditional distribution \(p(\mathbf y \mid \mathbf f, \ldots)\) that defines the likelihood.

Parameters:
  • function_samples – Samples from the function (\(\mathbf f\))

  • data – (Pyro integration only.) Additional variables that the likelihood needs to condition on. The keys of the dictionary will correspond to Pyro sample sites in the likelihood’s model/guide.

  • args – Additional args

  • kwargs – Additional kwargs

classmethod from_config(config)[source]
class aepsych.likelihoods.LinearBernoulliLikelihood(objective=None)[source]

Bases: _OneDimensionalLikelihood

A likelihood of the form Bernoulli(sigma(k(x+c))), where k and c are GPs and sigma is a flexible link function.

Initializes the linear bernoulli likelihood.

Parameters:

objective (Callable, optional) – Link function to use (sigma in the notation above). Defaults to probit with no floor.

f(function_samples, Xi)[source]

Return the latent function value, k(x-c).

Parameters:
  • function_samples (torch.Tensor) – Samples from a batched GP

  • Xi (torch.Tensor) – Intensity values.

Returns:

latent function value.

Return type:

torch.Tensor

p(function_samples, Xi)[source]

Returns the response probability sigma(k(x+c)).

Parameters:
  • function_samples (torch.Tensor) – Samples from the batched GP (see documentation for self.f)

  • Xi (torch.Tensor) – Intensity Values.

Returns:

Response probabilities.

Return type:

torch.Tensor

forward(function_samples, Xi, **kwargs)[source]

Forward pass for the likelihood

Parameters:
  • function_samples (torch.Tensor) – Samples from a batched GP of batch size 2.

  • Xi (torch.Tensor) – Intensity values.

Returns:

Outcome likelihood.

Return type:

torch.distributions.Bernoulli

expected_log_prob(observations, function_dist, *args, **kwargs)[source]

This has to be overridden to fix a bug in gpytorch where the kwargs aren’t being passed along to self.forward.

classmethod from_config(config)[source]
Parameters:

config (Config) –