Computes risk vs rejection rate curve and the area under this curve. Similar to risk-coverage curves [3] where
coverage instead of rejection rate is used.
References
Parameters:
y_true – array-like of shape (n_samples,)
ground truth labels.
y_prob – array-like of shape (n_samples, n_classes).
Probability scores from the base model.
y_pred – array-like of shape (n_samples,)
predicted labels.
selection_scores – scores corresponding to certainty in the predicted labels.
risk_func – risk function under consideration.
attributes – (optional) if risk function is a fairness metric also pass the protected attribute name.
num_bins – number of bins.
subgroup_ids – (optional) selectively compute risk on a subgroup of the samples specified by subgroup_ids.
return_counts – set to True to return counts also.
Returns:
aurrrc (float): area under risk rejection rate curve.
rejection_rates (list): rejection rates for each bin (returned only if return_counts is True).
selection_thresholds (list): selection threshold for each bin (returned only if return_counts is True).
risks (list): risk in each bin (returned only if return_counts is True).
Computes the metrics specified in the option which can be string or a list of strings. Default option all computes
the [aurrrc, ece, auroc, nll, brier, accuracy] metrics.
Parameters:
y_true – array-like of shape (n_samples,)
ground truth labels.
y_prob – array-like of shape (n_samples, n_classes).
Probability scores from the base model.
option – string or list of string contained the name of the metrics to be computed.
Entropy based decomposition [2] of predictive uncertainty into aleatoric and epistemic components.
References
Parameters:
y_prob_samples – ndarray of shape (mc_samples, n_samples, n_classes)
Samples from the predictive distribution. Here mc_samples stands for the number of Monte-Carlo samples,
n_samples is the number of data points and n_classes is the number of classes.
Returns:
total_uncertainty: entropy of the predictive distribution.
aleatoric_uncertainty: aleatoric component of the total_uncertainty.
epistemic_uncertainty: epistemic component of the total_uncertainty.
Plots the risk vs rejection rate curve showing the risk for different rejection rates. Multiple curves
can be plot by passing data as lists.
Parameters:
y_true – array-like or or a list of array-like of shape (n_samples,)
ground truth labels.
y_prob – array-like or or a list of array-like of shape (n_samples, n_classes).
Probability scores from the base model.
y_pred – array-like or or a list of array-like of shape (n_samples,)
predicted labels.
selection_scores – ndarray or a list of ndarray containing scores corresponding to certainty in the predicted labels.
risk_func – risk function under consideration.
attributes – (optional) if risk function is a fairness metric also pass the protected attribute name.
num_bins – number of bins.
subgroup_ids – (optional) ndarray or a list of ndarray containing subgroup_ids to selectively compute risk on a
subgroup of the samples specified by subgroup_ids.
Returns:
aurrrc_list: list containing the area under risk rejection rate curves.
rejection_rate_list: list containing the binned rejection rates.
selection_thresholds_list: list containing the binned selection thresholds.