probly.conformal_prediction.scores.lac.common

Common functions for LAC Nonconformity-Scores.

Functions

accretive_completion(prediction_sets, probs)

Implements Accretive Completion to eliminate empty prediction sets (Null Regions).

register(cls, func)

Register a class which can be used for LAC score computation.

Classes

LACScore(model)

LAC Nonconformity-Score.

class probly.conformal_prediction.scores.lac.common.LACScore(model)[source]

Bases: ClassificationScore

LAC Nonconformity-Score.

Parameters:

model (Predictor)

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]

Compute LAC scores.

Parameters:

probs (ndarray[Any, dtype[floating]])

Return type:

ndarray[Any, dtype[floating]]

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.lac.common.accretive_completion(prediction_sets, probs)[source]

Implements Accretive Completion to eliminate empty prediction sets (Null Regions).

Parameters:
  • prediction_sets (np.ndarray) – Boolean array of shape (n_samples, n_classes). True indicates the class is in the set.

  • probs (np.ndarray) – Array of shape (n_samples, n_classes). Usually conditional probabilities p(y|x). High score implies higher likelihood of the class.

Returns:

The modified prediction sets where every row has at least one True.

Return type:

np.ndarray

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

Register a class which can be used for LAC score computation.

Parameters:
  • cls (LazyType)

  • func (Callable)

Return type:

None