probly.conformal_prediction.scores.raps.common

Common functions for RAPS (Regularized Adaptive Prediction Sets) nonconformity scores.

Functions

register(cls, func)

Register implementation for specific type.

Classes

RAPSScore(model[, lambda_reg, k_reg, ...])

Regularized Adaptive Prediction Sets (RAPS) nonconformity score.

class probly.conformal_prediction.scores.raps.common.RAPSScore(model, lambda_reg=0.1, k_reg=0, epsilon=0.01, randomize=True, random_state=None)[source]

Bases: ClassificationScore

Regularized Adaptive Prediction Sets (RAPS) 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 RAPS scores with optional 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.raps.common.register(cls, func)[source]

Register implementation for specific type.

Parameters:
  • cls (LazyType)

  • func (Callable)

Return type:

None