Probabilistic output layer¶
We support a classification probabilistic output layer for classification and a regression probabilistic output layer for regression. Please find their references below.
- class fortuna.prob_output_layer.base.ProbOutputLayer[source]¶
Abstract probabilistic output layer class. 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. The probabilistic output layer is not join over different data points, and it acts on them individually.
- abstract entropy(outputs, **kwargs)[source]¶
Estimate the entropy of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- abstract log_prob(outputs, targets, **kwargs)[source]¶
Evaluate the log-probability density function (a.k.a. log-pdf) of target variables for each of the outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
targets (Array) – Target data points.
- Returns:
An evaluation of the log-pdf for each output.
- Return type:
jnp.ndarray
- abstract mean(outputs, **kwargs)[source]¶
Estimate the mean of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- abstract mode(outputs, **kwargs)[source]¶
Estimate the mode of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mode for each output.
- Return type:
jnp.ndarray
- abstract predict(outputs, **kwargs)[source]¶
Predict target variables starting from the calibrated outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
- Returns:
A predictions for each output.
- Return type:
jnp.ndarray
- property rng: RandomNumberGenerator¶
Invoke the random number generator object.
- Return type:
The random number generator object.
- abstract sample(n_target_samples, outputs, rng=None, **kwargs)[source]¶
Sample target variables for each outputs.
- Parameters:
n_target_samples (int) – The number of target samples to draw for each of the outputs.
outputs (Array) – Calibrated outputs.
rng (Optional[jax.Array]) – A random number generator. If not passed, this will be taken from the attributes of this class.
- Returns:
Samples of the target variable for each output.
- Return type:
jnp.ndarray
- std(outputs, variances=None)[source]¶
Estimate the standard deviation of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
variances (Optional[Array]) – Variance for each output.
- Returns:
The estimated standard deviation for each output.
- Return type:
jnp.ndarray
- class fortuna.prob_output_layer.classification.ClassificationMaskedProbOutputLayer[source]¶
Classification probabilistic output layers class. It characterizes the probability distribution of a target variable given a calibrated output logits as a Categorical distribution. That is \(p(y|\omega)=\text{Categorical}(y|p=\text{softmax}(\omega))\), where \(y\) denotes a target variable and \(\omega\) a calibrated output.
- entropy(outputs, **kwargs)¶
Estimate the entropy of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated entropy for each output.
- Return type:
jnp.ndarray
- log_prob(outputs, targets, **kwargs)[source]¶
Evaluate the log-probability density function (a.k.a. log-pdf) of target variables for each of the outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
targets (Array) – Target data points.
- Returns:
An evaluation of the log-pdf for each output.
- Return type:
jnp.ndarray
- mean(outputs, **kwargs)¶
Estimate the mean of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- mode(outputs, **kwargs)¶
Estimate the mode of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mode for each output.
- Return type:
jnp.ndarray
- predict(outputs, **kwargs)¶
Predict target variables starting from the calibrated outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
- Returns:
A predictions 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_target_samples, outputs, rng=None, **kwargs)¶
Sample target variables for each outputs.
- Parameters:
n_target_samples (int) – The number of target samples to draw for each of the outputs.
outputs (Array) – Calibrated outputs.
rng (Optional[jax.Array]) – A random number generator. If not passed, this will be taken from the attributes of this class.
- Returns:
Samples of the target variable for each output.
- Return type:
jnp.ndarray
- std(outputs, variances=None)¶
Estimate the standard deviation of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
variances (Optional[Array]) – Variance for each output.
- Returns:
The estimated standard deviation for each output.
- Return type:
jnp.ndarray
- variance(outputs, **kwargs)¶
Estimate the variance of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated variance for each output.
- Return type:
jnp.ndarray
- class fortuna.prob_output_layer.classification.ClassificationProbOutputLayer[source]¶
Classification probabilistic output layers class. It characterizes the probability distribution of a target variable given a calibrated output logits as a Categorical distribution. That is \(p(y|\omega)=\text{Categorical}(y|p=\text{softmax}(\omega))\), where \(y\) denotes a target variable and \(\omega\) a calibrated output.
- entropy(outputs, **kwargs)[source]¶
Estimate the entropy of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated entropy for each output.
- Return type:
jnp.ndarray
- log_prob(outputs, targets, **kwargs)[source]¶
Evaluate the log-probability density function (a.k.a. log-pdf) of target variables for each of the outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
targets (Array) – Target data points.
- Returns:
An evaluation of the log-pdf for each output.
- Return type:
jnp.ndarray
- mean(outputs, **kwargs)[source]¶
Estimate the mean of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- mode(outputs, **kwargs)[source]¶
Estimate the mode of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mode for each output.
- Return type:
jnp.ndarray
- predict(outputs, **kwargs)[source]¶
Predict target variables starting from the calibrated outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
- Returns:
A predictions 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_target_samples, outputs, rng=None, **kwargs)[source]¶
Sample target variables for each outputs.
- Parameters:
n_target_samples (int) – The number of target samples to draw for each of the outputs.
outputs (Array) – Calibrated outputs.
rng (Optional[jax.Array]) – A random number generator. If not passed, this will be taken from the attributes of this class.
- Returns:
Samples of the target variable for each output.
- Return type:
jnp.ndarray
- std(outputs, variances=None)[source]¶
Estimate the standard deviation of the one-hot encoded target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
variances (Optional[Array]) – Variance for each output.
- Returns:
The estimated standard deviation for each output.
- Return type:
jnp.ndarray
- class fortuna.prob_output_layer.regression.RegressionProbOutputLayer[source]¶
Regression probabilistic output layers class. It characterizes the probability distribution of a target variable given a calibrated output as a Gaussian distribution. That is \(p(y|\mu, \sigma^2)=\text{Normal}(y|\mu, \sigma^2)\), where \(y\) denotes a target variable and \(\omega=[\mu, \log\sigma^2]\) a calibrated output.
- credible_interval(outputs, n_target_samples=30, error=0.05, interval_type='two-tailed', rng=None)[source]¶
Estimate credible intervals for the target variable. This is supported only if the target variable is scalar.
- Parameters:
outputs (Array) – Model outputs.
n_target_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[jax.Array]) – A random number generator. If not passed, this will be taken from the attributes of this class.
- Returns:
A credibility interval for each of the outputs.
- Return type:
jnp.ndarray
- entropy(outputs, n_target_samples=30, rng=None, **kwargs)[source]¶
Estimate the entropy of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- log_prob(outputs, targets, **kwargs)[source]¶
Evaluate the log-probability density function (a.k.a. log-pdf) of target variables for each of the outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
targets (Array) – Target data points.
- Returns:
An evaluation of the log-pdf for each output.
- Return type:
jnp.ndarray
- mean(outputs, **kwargs)[source]¶
Estimate the mean of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mean for each output.
- Return type:
jnp.ndarray
- mode(outputs, **kwargs)[source]¶
Estimate the mode of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
- Returns:
The estimated mode for each output.
- Return type:
jnp.ndarray
- predict(outputs, **kwargs)[source]¶
Predict target variables starting from the calibrated outputs.
- Parameters:
outputs (Array) – Calibrated outputs.
- Returns:
A predictions 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_target_samples, outputs, rng=None, **kwargs)[source]¶
Sample target variables for each outputs.
- Parameters:
n_target_samples (int) – The number of target samples to draw for each of the outputs.
outputs (Array) – Calibrated outputs.
rng (Optional[jax.Array]) – A random number generator. If not passed, this will be taken from the attributes of this class.
- Returns:
Samples of the target variable for each output.
- Return type:
jnp.ndarray
- std(outputs, variances=None)¶
Estimate the standard deviation of the target variable given the output with respect to the probabilistic output layer distribution.
- Parameters:
outputs (Array) – Model outputs
variances (Optional[Array]) – Variance for each output.
- Returns:
The estimated standard deviation for each output.
- Return type:
jnp.ndarray