climb.tool.impl.data_suite.third_party.uq360.algorithms.variational_bayesian_neural_networks package¶
Submodules¶
climb.tool.impl.data_suite.third_party.uq360.algorithms.variational_bayesian_neural_networks.bnn module¶
- class climb.tool.impl.data_suite.third_party.uq360.algorithms.variational_bayesian_neural_networks.bnn.BnnClassification(config, prior='Gaussian', device=None)[source]¶
Bases:
BuiltinUQVariationally trained BNNs with Gaussian and Horseshoe [6] priors for classification.
- fit(X=None, y=None, train_loader=None)[source]¶
Fits BNN regression model.
- 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. 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.
train_loader – pytorch train_loader object.
- Returns:
self
- predict(X, mc_samples=100)[source]¶
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)
Samples from the predictive distribution.
- Return type:
namedtuple
- class climb.tool.impl.data_suite.third_party.uq360.algorithms.variational_bayesian_neural_networks.bnn.BnnRegression(config, prior='Gaussian')[source]¶
Bases:
BuiltinUQVariationally trained BNNs with Gaussian and Horseshoe [6] priors for regression.
References
- fit(X, y)[source]¶
Fit the BNN regression model.
- Parameters:
X – array-like of shape (n_samples, n_features). Features vectors of the training data.
y – array-like of shape (n_samples,) or (n_samples, n_targets) Target values
- Returns:
self
- predict(X, mc_samples=100, return_dists=False, return_epistemic=True, return_epistemic_dists=False)[source]¶
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).
- 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.
Only returned when return_dists is True.
- Return type:
namedtuple