probly.conformal_prediction.scores.aps.common

APS Score implementation with optional Randomization (U-term).

Functions

register(cls, func)

Register a implementation for a specific type.

Classes

APSScore(model[, randomize, random_state])

Adaptive Prediction Sets (APS) nonconformity score.

class probly.conformal_prediction.scores.aps.common.APSScore(model, randomize=True, random_state=None)[source]

Bases: ClassificationScore

Adaptive Prediction Sets (APS) 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 APS 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

probly.conformal_prediction.scores.aps.common.register(cls, func)[source]

Register a implementation for a specific type.

Parameters:
  • cls (LazyType)

  • func (Callable)

Return type:

None