incerto.conformal.ConformalPredictor#
- class incerto.conformal.ConformalPredictor(predictor, method='unknown', alpha=0.0)[source]#
Bases:
objectThin wrapper around a calibrated conformal predictor.
Provides a consistent object-oriented interface for both classification (prediction sets) and regression (intervals) conformal methods.
- Parameters:
Example
>>> cp = ConformalPredictor.from_method( ... "raps", model=model, calib_loader=loader, alpha=0.1 ... ) >>> pred_sets = cp.predict(x_test)
Methods
__init__(predictor[, method, alpha])from_method(method, **kwargs)Convenience factory that calls the named method and wraps the result.
predict(x)Run the calibrated predictor on new inputs.
- predict(x)[source]#
Run the calibrated predictor on new inputs.
For classification: returns
List[torch.Tensor]of prediction sets. For regression: returns(lower, upper)interval bounds.
- classmethod from_method(method, **kwargs)[source]#
Convenience factory that calls the named method and wraps the result.
- Parameters:
method (
str) – One of'inductive_conformal','mondrian_conformal','aps','raps','jackknife_plus','cv_plus','conformalized_quantile_regression'.**kwargs – Arguments forwarded to the method function.
- Return type:
- Returns:
A
ConformalPredictorwrapping the calibrated predictor.