interval_classifier

probly.transformation.interval_classifier(base: Predictor[In, Out], use_base_weights: bool = False) IntervalClassifierPredictor[In, Out][source]

Create an interval classifier from a base classifier based on [WCM+24].

Replaces every Conv2d, BatchNorm2d, BatchNorm1d, and Linear in the base network with its interval counterpart, and replaces the last Linear with the credal head IntLinear -> IntBatchNorm1d -> IntSoftmax. Any trailing softmax in a ProbabilisticClassifier base is stripped.

Parameters:
  • base – Base predictor; must be a ProbabilisticClassifier or LogitClassifier.

  • use_base_weights – If True, copy each replaced layer’s weights, biases and (for BatchNorm) running statistics into the new layer’s center_* slots. The radius parameters keep their fresh initialization. If False, every interval layer starts from scratch (matching how methods like dropout behave by default).

Returns:

The transformed interval classifier predictor.

Raises:

ValueError – If base contains no nn.Linear for the credal head to replace.