safeai.rgr.rgr_score
- safeai.rgr.rgr_score(pred_original, pred_perturbed, *, class_order=None, class_weights=None, verbose=False)[source]
Compute Rank Graduation Robustness between two prediction arrays.
- Parameters:
pred_original (array-like) – Original predictions. Can be a 1D score vector or a 2D probability matrix.
pred_perturbed (array-like) – Predictions after perturbation. Must have the same shape as pred_original.
class_order (array-like, optional) – Class order. If provided with 1D binary probabilities, the vectors are converted to two-column probability matrices.
class_weights (array-like, optional) – Weights for multiclass aggregation. If None, uses uniform weights.
verbose (bool, default=False) – Whether to print per-class values for multiclass inputs.
- Returns:
RGR score.
- Return type:
float