Likelihood function#

The likelihood function models the target data given the model and the input data. We support a classification likelihood for classification and a regression likelihood for regression. Please find their references below.

class fortuna.likelihood.classification.ClassificationLikelihood(model_manager, prob_output_layer, output_calib_manager=None)[source]#

A classification likelihood function class. In this class, the likelihood function is additionally assumed to be a probability density function, i.e. positive and integrating to 1. The likelihood is formed by three objects applied in sequence: the model manager, the output calibrator and the probabilistic output layer. The model manager maps parameters and inputs to outputs. The output calibration takes outputs and returns some calibrated version of them. The probabilistic output layer describes the probability distribution of the calibrated outputs.

Parameters:
  • model_manager (ModelManager) – An model manager. This objects orchestrates the evaluation of the models.

  • prob_output_layer (ProbOutputLayer) – A probabilistic output layer object. This object characterizes the probability distribution of the target variable given the calibrated outputs.

  • output_calib_manager (Optional[OutputCalibManager]) – An output calibration manager object. It transforms outputs of the model manager into some calibrated version of them.

entropy(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood entropy, that is

\[-\mathbb{E}_{Y|w,x}[\log p(Y|w,x)]\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood entropy for each input.

Return type:

jnp.ndarray

get_calibrated_outputs(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Compute the outputs and their calibrated version.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The calibrated outputs.

Return type:

jnp.ndarray

get_outputs(params, inputs_loader, mutable=None, distribute=True, **kwargs)#

Compute the outputs and their calibrated version.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The calibrated outputs.

Return type:

jnp.ndarray

log_prob(params, data_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Evaluate the log-likelihood function.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • data_loader (DataLoader) – A data loader.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The evaluation of the log-likelihood function.

Return type:

jnp.ndarray

mean(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood mean of the one-hot encoded target variable, that is

\[\mathbb{E}_{\tilde{Y}|w, x}[\tilde{Y}],\]
where:
  • \(x\) is an observed input variable;

  • \(\tilde{Y}\) is a one-hot encoded random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood mean for each input.

Return type:

jnp.ndarray

mode(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Estimate the likelihood mode of the target variable, that is

\[\text{argmax}_y\ p(y|w, x),\]
where:
  • \(x\) is an observed input variable;

  • \(w\) denotes the observed model parameters;

  • \(y\) is the target variable to optimize upon.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood mode for each input.

Return type:

jnp.ndarray

property rng: RandomNumberGenerator#

Invoke the random number generator object.

Return type:

The random number generator object.

sample(n_target_samples, params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, return_aux=None, rng=None, distribute=True, **kwargs)#

Sample target variables from the likelihood function for each input variable.

Parameters:
  • n_target_samples (int) – The number of samples to draw from the likelihood for each input data point.

  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • return_aux (Optional[List[str]]) – The auxiliary objects to return. We support ‘outputs’. If this argument is not given, no auxiliary object is returned.

  • rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The samples of the target variable for each input. If return_aux is given, the corresponding auxiliary objects are also returned.

Return type:

Union[jnp.ndarray, Tuple[jnp.ndarray, dict]]

std(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, variance=None, distribute=True, **kwargs)#

Estimate the likelihood standard deviation of the target variable, that is

\[\sqrt{\text{Var}_{Y|w,x}[Y]},\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • variance (Optional[jnp.ndarray]) – An estimate of the likelihood variance for each input.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood standard deviation for each input.

Return type:

jnp.ndarray

variance(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood variance of the one-hot encoded target variable, that is

\[\text{Var}_{\tilde{Y}|w,x}[\tilde{Y}],\]
where:
  • \(x\) is an observed input variable;

  • \(\tilde{Y}\) is a one-hot encoded random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood variance for each input.

Return type:

jnp.ndarray

class fortuna.likelihood.regression.RegressionLikelihood(model_manager, prob_output_layer, output_calib_manager=None)[source]#

A regression likelihood function class. In this class, the likelihood function is additionally assumed to be a probability density function, i.e. positive and integrating to 1. The likelihood is formed by three objects applied in sequence: the model manager, the output calibrator and the probabilistic output layer. The model manager maps parameters and inputs to outputs. The output calibration takes outputs and returns some calibrated version of them. The probabilistic output layer describes the probability distribution of the calibrated outputs.

Parameters:
  • model_manager (ModelManager) – An model manager. This objects orchestrates the evaluation of the models.

  • prob_output_layer (ProbOutputLayer) – A probabilistic output layer object. This object characterizes the probability distribution of the target variable given the calibrated outputs.

  • output_calib_manager (Optional[OutputCalibManager]) – An output calibration manager object. It transforms outputs of the model manager into some calibrated version of them.

entropy(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, n_target_samples=30, rng=None, distribute=True, **kwargs)[source]#

Estimate the likelihood entropy, that is

\[-\mathbb{E}_{Y|w,x}[\log p(Y|w,x)]\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood entropy for each input.

Return type:

jnp.ndarray

get_calibrated_outputs(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Compute the outputs and their calibrated version.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The calibrated outputs.

Return type:

jnp.ndarray

get_outputs(params, inputs_loader, mutable=None, distribute=True, **kwargs)#

Compute the outputs and their calibrated version.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The calibrated outputs.

Return type:

jnp.ndarray

log_prob(params, data_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Evaluate the log-likelihood function.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • data_loader (DataLoader) – A data loader.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The evaluation of the log-likelihood function.

Return type:

jnp.ndarray

mean(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Estimate the likelihood mean of the target variable, that is

\[\mathbb{E}_{Y|w, x}[Y],\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood mean for each input.

Return type:

jnp.ndarray

mode(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Estimate the likelihood mode of the target variable, that is

\[\text{argmax}_y\ p(y|w, x),\]
where:
  • \(x\) is an observed input variable;

  • \(w\) denotes the observed model parameters;

  • \(y\) is the target variable to optimize upon.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood mode for each input.

Return type:

jnp.ndarray

quantile(q, params=None, inputs_loader=None, mutable=None, calib_params=None, calib_mutable=None, n_target_samples=30, target_samples=None, rng=None, distribute=True, **kwargs)[source]#

Estimate the q-th quantiles of the likelihood function.

Parameters:
  • q (Union[float, jnp.ndarray, np.ndarray]) – Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive.

  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • n_target_samples (int) – Number of target samples to sample for each input data point.

  • target_samples (Optional[jnp.ndarray] = None) – Samples of the target variable for each input, used to estimate the quantiles.

  • rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

Quantile estimate for each quantile and each input. If multiple quantiles q are given, the result’s first axis is over different quantiles.

Return type:

jnp.ndarray

property rng: RandomNumberGenerator#

Invoke the random number generator object.

Return type:

The random number generator object.

sample(n_target_samples, params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, return_aux=None, rng=None, distribute=True, **kwargs)#

Sample target variables from the likelihood function for each input variable.

Parameters:
  • n_target_samples (int) – The number of samples to draw from the likelihood for each input data point.

  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • return_aux (Optional[List[str]]) – The auxiliary objects to return. We support ‘outputs’. If this argument is not given, no auxiliary object is returned.

  • rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The samples of the target variable for each input. If return_aux is given, the corresponding auxiliary objects are also returned.

Return type:

Union[jnp.ndarray, Tuple[jnp.ndarray, dict]]

std(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, variance=None, distribute=True, **kwargs)#

Estimate the likelihood standard deviation of the target variable, that is

\[\sqrt{\text{Var}_{Y|w,x}[Y]},\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • variance (Optional[jnp.ndarray]) – An estimate of the likelihood variance for each input.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood standard deviation for each input.

Return type:

jnp.ndarray

variance(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)#

Estimate the likelihood variance of the target variable, that is

\[\text{Var}_{Y|w,x}[Y],\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood variance for each input.

Return type:

jnp.ndarray

class fortuna.likelihood.base.Likelihood(model_manager, prob_output_layer, output_calib_manager)[source]#

A likelihood function abstract class. In this class, the likelihood function is additionally assumed to be a probability density function, i.e. positive and integrating to 1. The likelihood is formed by three objects applied in sequence: the model manager, the output calibrator and the probabilistic output layer. The output maker maps parameters and inputs to outputs. The output calibration takes outputs and returns some calibrated version of them. The probabilistic output layer describes the probability distribution of the calibrated outputs.

Parameters:
  • model_manager (ModelManager) – An model manager. This objects orchestrates the evaluation of the models.

  • prob_output_layer (ProbOutputLayer) – A probabilistic output layer object. This object characterizes the probability distribution of the target variable given the calibrated outputs.

  • output_calib_manager (OutputCalibManager) – An output calibration manager object. It transforms outputs of the model manager into some calibrated version of them.

abstract entropy(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood entropy, that is

\[-\mathbb{E}_{Y|w,x}[\log p(Y|w,x)]\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood entropy for each input.

Return type:

jnp.ndarray

get_calibrated_outputs(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Compute the outputs and their calibrated version.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The calibrated outputs.

Return type:

jnp.ndarray

get_outputs(params, inputs_loader, mutable=None, distribute=True, **kwargs)[source]#

Compute the outputs and their calibrated version.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The calibrated outputs.

Return type:

jnp.ndarray

log_prob(params, data_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Evaluate the log-likelihood function.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • data_loader (DataLoader) – A data loader.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The evaluation of the log-likelihood function.

Return type:

jnp.ndarray

mean(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood mean of the target variable, that is

\[\mathbb{E}_{Y|w, x}[Y],\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood mean for each input.

Return type:

jnp.ndarray

mode(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood mode of the target variable, that is

\[\text{argmax}_y\ p(y|w, x),\]
where:
  • \(x\) is an observed input variable;

  • \(w\) denotes the observed model parameters;

  • \(y\) is the target variable to optimize upon.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood mode for each input.

Return type:

jnp.ndarray

property rng: RandomNumberGenerator#

Invoke the random number generator object.

Return type:

The random number generator object.

sample(n_target_samples, params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, return_aux=None, rng=None, distribute=True, **kwargs)[source]#

Sample target variables from the likelihood function for each input variable.

Parameters:
  • n_target_samples (int) – The number of samples to draw from the likelihood for each input data point.

  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • return_aux (Optional[List[str]]) – The auxiliary objects to return. We support ‘outputs’. If this argument is not given, no auxiliary object is returned.

  • rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

The samples of the target variable for each input. If return_aux is given, the corresponding auxiliary objects are also returned.

Return type:

Union[jnp.ndarray, Tuple[jnp.ndarray, dict]]

std(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, variance=None, distribute=True, **kwargs)[source]#

Estimate the likelihood standard deviation of the target variable, that is

\[\sqrt{\text{Var}_{Y|w,x}[Y]},\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • variance (Optional[jnp.ndarray]) – An estimate of the likelihood variance for each input.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood standard deviation for each input.

Return type:

jnp.ndarray

variance(params, inputs_loader, mutable=None, calib_params=None, calib_mutable=None, distribute=True, **kwargs)[source]#

Estimate the likelihood variance of the target variable, that is

\[\text{Var}_{Y|w,x}[Y],\]
where:
  • \(x\) is an observed input variable;

  • \(Y\) is a random target variable;

  • \(w\) denotes the observed model parameters.

Parameters:
  • params (Params) – The random parameters of the probabilistic model.

  • inputs_loader (InputsLoader) – A loader of input data points.

  • mutable (Optional[Mutable]) – The mutable objects used to evaluate the models.

  • calib_params (Optional[CalibParams]) – The calibration parameters of the probabilistic model.

  • calib_mutable (Optional[CalibMutable]) – The calibration mutable objects used to evaluate the calibrators.

  • distribute (bool) – Whether to distribute computation over multiple devices, if available.

Returns:

An estimate of the likelihood variance for each input.

Return type:

jnp.ndarray