Predictive distribution#
The predictive distribution is the component of the probabilistic model responsible for the computation of predictive statistics. We support a classification predictive for classification and a regression predictive for regression. Please find their references below.
- class fortuna.output_calib_model.predictive.classification.ClassificationPredictive(output_calib_manager, prob_output_layer)[source]#
Abstract predictive distribution. It characterizes the distribution of the target variable given the calibrated outputs. It can be see as \(p(y|\omega)\), where \(y\) is a target variable and \(\omega\) a calibrated output.
- entropy(outputs, calibrated=True, **kwargs)#
Estimate the entropy of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (jnp.ndarray) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- log_prob(outputs, targets, calibrated=True, **kwargs)#
Evaluate the log-probability density function (a.k.a. log-pdf) given the outputs and target data.
- Parameters:
outputs (Array) – Calibrated outputs.
targets (Array) – Target data points.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
An evaluation of the log-pdf for each data point.
- Return type:
jnp.ndarray
- mean(outputs, calibrated=True, **kwargs)[source]#
Estimate the mean of the one-hot encoded target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (Array) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- mode(outputs, calibrated=True, **kwargs)[source]#
Estimate the mode of the one-hot encoded target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (Array) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated mode for each output.
- Return type:
jnp.ndarray
- property rng: RandomNumberGenerator#
Invoke the random number generator object.
- Return type:
The random number generator object.
- sample(n_samples, outputs, rng=None, calibrated=True, **kwargs)#
Sample target variables for each outputs.
- Parameters:
n_samples (int) – The number of target samples to draw for each of the outputs.
outputs (Array) – Calibrated outputs.
rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
Samples of the target variable for each output.
- Return type:
jnp.ndarray
- std(outputs, variances=None, calibrated=True)[source]#
Estimate the standard deviation of the one-hot encoded target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (jnp.ndarray) – Model outputs.
variances (Optional[jnp.ndarray]) – Variance for each output.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated standard deviation for each output.
- Return type:
jnp.ndarray
- variance(outputs, calibrated=True, **kwargs)[source]#
Estimate the variance of the one-hot encoded target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (jnp.ndarray) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated variance for each output.
- Return type:
jnp.ndarray
- class fortuna.output_calib_model.predictive.regression.RegressionPredictive(output_calib_manager, prob_output_layer)[source]#
Abstract predictive distribution. It characterizes the distribution of the target variable given the calibrated outputs. It can be see as \(p(y|\omega)\), where \(y\) is a target variable and \(\omega\) a calibrated output.
- credible_interval(outputs, n_samples=30, error=0.05, interval_type='two-tailed', rng=None, calibrated=True)[source]#
Estimate a credible interval of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (Array) – Model outputs.
n_samples (int) – Number of target samples to draw for each output.
error (float) – The interval error. This must be a number between 0 and 1, extremes included. For example, error=0.05 corresponds to a 95% level of credibility.
interval_type (str) – The interval type. We support “two-tailed” (default), “right-tailed” and “left-tailed”.
rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated credible interval for each output.
- Return type:
jnp.ndarray
- entropy(outputs, calibrated=True, **kwargs)#
Estimate the entropy of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (jnp.ndarray) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- log_prob(outputs, targets, calibrated=True, **kwargs)#
Evaluate the log-probability density function (a.k.a. log-pdf) given the outputs and target data.
- Parameters:
outputs (Array) – Calibrated outputs.
targets (Array) – Target data points.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
An evaluation of the log-pdf for each data point.
- Return type:
jnp.ndarray
- mean(outputs, calibrated=True, **kwargs)#
Estimate the mean of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (Array) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- mode(outputs, calibrated=True, **kwargs)#
Estimate the mode of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (Array) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated mode for each output.
- Return type:
jnp.ndarray
- quantile(q, outputs, n_samples=30, rng=None, calibrated=True)[source]#
Estimate the quantile of the target variable given the output, with respect to the predictive distribution.
- Parameters:
q (Union[float, Array, List]) – Quantile(s) to estimate.
outputs (jnp.ndarray) – Model outputs.
n_samples (Optional[int]) – Number of target samples to draw when computing quantiles.
rng (Optional[PRNGKeyArray]) – A random number generator.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated quantiles for each output.
- Return type:
jnp.ndarray
- property rng: RandomNumberGenerator#
Invoke the random number generator object.
- Return type:
The random number generator object.
- sample(n_samples, outputs, rng=None, calibrated=True, **kwargs)#
Sample target variables for each outputs.
- Parameters:
n_samples (int) – The number of target samples to draw for each of the outputs.
outputs (Array) – Calibrated outputs.
rng (Optional[PRNGKeyArray]) – A random number generator. If not passed, this will be taken from the attributes of this class.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
Samples of the target variable for each output.
- Return type:
jnp.ndarray
- std(outputs, variances=None, calibrated=True)#
Estimate the standard deviation of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (jnp.ndarray) – Model outputs.
variances (Optional[jnp.ndarray]) – Variance for each output.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated standard deviation for each output.
- Return type:
jnp.ndarray
- variance(outputs, calibrated=True, **kwargs)#
Estimate the variance of the target variable given the output, with respect to the predictive distribution.
- Parameters:
outputs (jnp.ndarray) – Model outputs.
calibrated (bool) – Whether the outputs should be calibrated when computing this method. If calibrated is set to True, the model must have been calibrated beforehand.
- Returns:
The estimated variance for each output.
- Return type:
jnp.ndarray