In addition to the mean and lower/upper bounds, also returns epistemic uncertainty (return_epistemic=True)
and full predictive distribution (return_dists=True).
Parameters:
X – array-like of shape (n_samples, n_features).
Features vectors of the test points.
return_dists – If True, the predictive distribution for each instance using scipy distributions is returned.
return_epistemic – if True, the epistemic upper and lower bounds are returned.
return_epistemic_dists – If True, the epistemic distribution for each instance using scipy distributions
is returned.
Returns:
A namedtuple that holds
y_mean: ndarray of shape (n_samples, [n_output_dims])
Mean of predictive distribution of the test points.
y_lower: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of predictive distribution of the test points.
y_upper: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of predictive distribution of the test points.
y_lower_epistemic: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of epistemic component of the predictive distribution of the test points.
Only returned when return_epistemic is True.
y_upper_epistemic: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of epistemic component of the predictive distribution of the test points.
Only returned when return_epistemic is True.
dists: list of predictive distribution as scipy.stats objects with length n_samples.
Wrapper for heteroscedastic regression. We learn to predict targets given features,
assuming that the targets are noisy and that the amount of noise varies between data points.
https://en.wikipedia.org/wiki/Heteroscedasticity
Parameters:
model_type – The base model architecture. Currently supported values are [mlp].
mlp modeltype learns a multi-layer perceptron with a heteroscedastic Gaussian likelihood. Both the
mean and variance of the Gaussian are functions of the data point ->git N(y_n | mlp_mu(x_n), mlp_var(x_n))
model – (optional) The prediction model. Currently support pytorch models that returns mean and log variance.
config – dictionary containing the config parameters for the model.
device – device used for pytorch models ignored otherwise.
verbose – if True, print statements with the progress are enabled.
In addition to the mean and lower/upper bounds, also returns epistemic uncertainty (return_epistemic=True)
and full predictive distribution (return_dists=True).
Parameters:
X – array-like of shape (n_samples, n_features).
Features vectors of the test points.
return_dists – If True, the predictive distribution for each instance using scipy distributions is returned.
Returns:
A namedtupe that holds
y_mean: ndarray of shape (n_samples, [n_output_dims])
Mean of predictive distribution of the test points.
y_lower: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of predictive distribution of the test points.
y_upper: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of predictive distribution of the test points.
dists: list of predictive distribution as scipy.stats objects with length n_samples.
Ensemble Regression assumes an ensemble of models of Gaussian form for the predictive distribution and
returns the mean and log variance of the ensemble of Gaussians.
Initializer for Ensemble of heteroscedastic regression.
:param model_type: The base model used for predicting a quantile. Currently supported values are [heteroscedasticregression].
:param config: dictionary containing the config parameters for the model.
:param device: device used for pytorch models ignored otherwise.
Obtain predictions for the test points.
In addition to the mean and lower/upper bounds, also returns epistemic uncertainty (return_epistemic=True)
and full predictive distribution (return_dists=True).
:param X: array-like of shape (n_samples, n_features).
Features vectors of the test points.
Parameters:
return_dists – If True, the predictive distribution for each instance using scipy distributions is returned.
Returns:
A namedtupe that holds
y_mean: ndarray of shape (n_samples, [n_output_dims])
Mean of predictive distribution of the test points.
y_lower: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of predictive distribution of the test points.
y_upper: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of predictive distribution of the test points.
dists: list of predictive distribution as scipy.stats objects with length n_samples.
ActivelyLearnedModel assumes an existing BuiltinUQ model, and implements an active learning training of this model. This code is supporting Pestourie et al. “Active learning of deep surrogates for PDEs: application to metasurface design.” npj Computational Materials 6.1 (2020): 1-7.
Initializer for Actively learned model.
:param config: dictionary containing the config parameters for the model. For active learning: num_init, T, K, M, sampling_function, querry_function, for the used model:
{“model_function”: BuilInUQ model to actively learn,
“model_args”: same arguments as the BuilInUQ model used,
“model_kwargs”: same keyword arguments as the BuilInUQ model used}
Parameters:
device – device used for pytorch models ignored otherwise.
Fit the actively learned model, by increasing the dataset efficiently. NB: it does not take a dataset as argument, because it is building one during training.
:returns: self
Obtain predictions for the test points.
In addition to the mean and lower/upper bounds, also returns epistemic uncertainty (return_epistemic=True)
and full predictive distribution (return_dists=True).
:param X: array-like of shape (n_samples, n_features).
Features vectors of the test points.
Returns:
A namedtupe that holds
y_mean: ndarray of shape (n_samples, [n_output_dims])
Mean of predictive distribution of the test points.
y_lower: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of predictive distribution of the test points.
y_upper: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of predictive distribution of the test points.
In addition to the mean and lower/upper bounds, also returns epistemic uncertainty (return_epistemic=True)
and full predictive distribution (return_dists=True).
Parameters:
X – array-like of shape (n_samples, n_features).
Features vectors of the test points.
Returns:
A namedtupe that holds
y_mean: ndarray of shape (n_samples, [n_output_dims])
Mean of predictive distribution of the test points.
y_lower: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of predictive distribution of the test points.
y_upper: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of predictive distribution of the test points.
In addition to the mean and lower/upper bounds, also returns epistemic uncertainty (return_epistemic=True)
and full predictive distribution (return_dists=True).
Parameters:
X – array-like of shape (n_samples, n_features).
Features vectors of the test points.
mc_samples – Number of Monte-Carlo samples.
return_dists – If True, the predictive distribution for each instance using scipy distributions is returned.
return_epistemic – if True, the epistemic upper and lower bounds are returned.
return_epistemic_dists – If True, the epistemic distribution for each instance using scipy distributions
is returned.
Returns:
A namedtupe that holds
y_mean: ndarray of shape (n_samples, [n_output_dims])
Mean of predictive distribution of the test points.
y_lower: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of predictive distribution of the test points.
y_upper: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of predictive distribution of the test points.
y_lower_epistemic: ndarray of shape (n_samples, [n_output_dims])
Lower quantile of epistemic component of the predictive distribution of the test points.
Only returned when return_epistemic is True.
y_upper_epistemic: ndarray of shape (n_samples, [n_output_dims])
Upper quantile of epistemic component of the predictive distribution of the test points.
Only returned when return_epistemic is True.
dists: list of predictive distribution as scipy.stats objects with length n_samples.
X – array-like of shape (n_samples, n_features) or (n_samples, n_classes).
Features vectors of the training data or the probability scores from the base model.
Ignored if train_loader is not None.
y – array-like of shape (n_samples,) or (n_samples, n_targets)
Target values
Ignored if train_loader is not None.
Obtain calibrated predictions for the test points.
Parameters:
X – array-like of shape (n_samples, n_features) or (n_samples, n_classes).
Features vectors of the training data or the probability scores from the base model.
mc_samples – Number of Monte-Carlo samples.
Returns:
A namedtupe that holds
y_pred: ndarray of shape (n_samples,)
Predicted labels of the test points.
y_prob: ndarray of shape (n_samples, n_classes)
Predicted probability scores of the classes.
y_prob_var: ndarray of shape (n_samples,)
Variance of the prediction on the test points.
y_prob_samples: ndarray of shape (mc_samples, n_samples, n_classes)