probly.conformal_prediction.scores.saps.common

Common for SAPS scores.

Functions

register(cls, func)

Register an implementation for a specific type.

Classes

SAPSScore(model[, lambda_val, random_state])

Sorted Adaptive Prediction Sets (SAPS) nonconformity score.

class probly.conformal_prediction.scores.saps.common.SAPSScore(model, lambda_val=0.1, random_state=42)[source]

Bases: ClassificationScore

Sorted Adaptive Prediction Sets (SAPS) nonconformity score.

Parameters:
calibration_nonconformity(x_cal, y_cal, probs=None)

Compute calibration scores (vectorized, backend-agnostic).

Parameters:
  • x_cal (Sequence[Any])

  • y_cal (Sequence[Any])

  • probs (Any | None)

Return type:

npt.NDArray[np.floating]

compute_score(probs)[source]

Calculate SAPS scores with randomization U-term.

Parameters:

probs (Any)

Return type:

Any

predict_nonconformity(x_test, probs=None)

Compute scores for all labels (stays on original device).

Parameters:
  • x_test (Sequence[Any])

  • probs (Any | None)

Return type:

Any

rng: Generator
probly.conformal_prediction.scores.saps.common.register(cls, func)[source]

Register an implementation for a specific type.

Parameters:
  • cls (LazyType)

  • func (Callable)

Return type:

None