GaussianRegression¶
The gaussian regression model is an extension of the regression task. In regression, we try to predict the value of a target variable as a function of the values of the independent variables. However, the uncertainty of the prediction is not taken into account and it can be problematic during the modelisation. However, it is difficult to assess the quality of the uncertainty as this information is not really available.
The uncertainty can be separated into two parts :
Aleatoric uncertainty
: the uncertainty linked to the distribution of the data
Epistemic uncertainty
: the uncertainty related to the power of the model, the uncertainty related to the estimation of the model parameters and the uncertainty related to the collection of (incomplete, noisy, discordant, …).
Modelling uncertainty can be done by modelling the distribution of the prediction.
It is not possible to predict the whole distribution of the prediction. One solution
is to predict some quantiles of the distribution and another solution is to predict
the parameters of a known distribution. In the case of GaussianRegression
,
this is the second solution and the model tries to predict the mean and the
variance of a gaussian distribution associated with the prediction.
Warning
According to the model, it is possible to separate the variance into an aleatoric and epistemic component. Therefore, the the number of outputs can be different.
Tip
It is possible to use GaussianRegression
with a standard deterministic model.
However, when you will call the method predict`
, it will only send you the mean. It
is useful to utilize the class to scale and unscale the data.
- class purestochastic.model.base_uncertainty_models.GaussianRegression(model)[source]¶
The class is designed for gaussian regression, in other words models that predict the mean and the variance associated of a gaussian distribution associated with the prediction. This class can work with deterministic and stochastic models.
- evaluate(X, y, metrics=None, stochastic_metrics=None, **kwargs)[source]¶
Evaluate the model. It takes as input a matrix of input values X and a matrix of target values y. It computes different metrics on the model’s predictions and the target values. If evaluation metrics are not specified, the function uses the metrics given in the compile method of the model. Metrics can be a list of metrics or a single metric and need to be separated between deterministic metrics and stochastic metrics. For more information, see StochasticModel.
- Parameters
X (numpy.ndarray) – a matrix of input values
y (numpy.ndarray) – a matrix of target values
metrics (keras.metrics.Metric) – a list of metrics to be computed on the model’s predictions and the target values.
stochastic_metrics (keras.metrics.Metric) – a list of metrics to be computed on the model’s predictions and the target values.
- Return type
A dictionary of metrics.
- fit(X, y, standardize=True, **kwargs)[source]¶
Train the model. It takes as input a matrix of input values X and a matrix of target values y. If standardize is set to true, the input values are standardized.
- Parameters
X (numpy.ndarray) – a matrix of input values
y (numpy.ndarray) – a matrix of target values
standardize (boolean) – specify if the input and the target values have to be scaled
- Return type
A History object from the fit method of the model.
- load_weights(filepath, **kwargs)[source]¶
Loads the model’s weights.
- Parameters
filepath (string) – the path where the weights are saved.
**kwargs (dict) – a dictionary of parameters to be passed to the load_weights method of the tf.keras.Model.
- predict(X, **kwargs)[source]¶
Computes the model’s prediction. It takes as input a matrix of input values X. It outputs predictions made on the input values.
- Parameters
X (numpy.ndarray) – a matrix of input values
- Returns
It always outputs a matrix for the mean predictions made on the input values.
It can also output the variance if the model output the variance.
It type_var==”sum”, the variance is the sum of the aleatoric and epistemic variances.
Otherwise, the two types are returned separately.
- save_weights(filepath, **kwargs)[source]¶
Saves the model’s weights.
- Parameters
filepath (string) – the path where the weights needs to be saved.
**kwargs (dict) – a dictionary of parameters to be passed to the save_weights method of the tf.keras.Model.
- unstandardize_prediction(mean, variance_epi=None, variance_alea=None)[source]¶
The goal of this method is to unstandardize the prediction wheter it’s the variance or the mean of the prediction.
- Parameters
mean (np.array) – The predicted mean.
variance_epi (np.array (optional)) – The predicted epistemic variance.
variance_alea (np.array (optional)) – The predicted aleatoric variance.
- Return type
The prediction which have been unstandardize.
References
- 1
Moloud Abdar et al. « A review of uncertainty quantification in deep learning : Techniques, applications and challenges ». In : Information Fusion 76 (2021), p. 243-297. issn : 15662535. doi : 10.1016/j.inffus.2021.05.008. arXiv : 2011.06225.