probly.method.conformal.sklearn.SklearnConformalSetPredictor

class probly.method.conformal.sklearn.SklearnConformalSetPredictor(predictor: BaseEstimator, non_conformity_score: NonConformityScore[Out, np.ndarray])[source]

Bases: _ConformalPredictorBase[In, Out], BaseEstimator, Generic[In, Out]

Base sklearn conformal wrapper forwarding sklearn APIs.

Initialize the sklearn conformal wrapper.

calibrate(alpha: float, y_calib: Out, *calib_args: In.args, **calib_kwargs: In.kwargs) Self[source]

Calibrate the predictor using calibration data.

conformal_quantile
property estimator: BaseEstimator

Alias to sklearn’s conventional attribute name for wrapped estimators.

fit(x_calib: object, y_calib: object, *, alpha: float | None = None, **calib_kwargs: object) SklearnConformalSetPredictor[In, Out][source]

Calibrate conformal state.

get_metadata_routing()[source]

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

non_conformity_score
predict(*args: object, **kwargs: object) Any[source]

Forward predict to the wrapped estimator.

predictor: BaseEstimator
set_fit_request(*, alpha: bool | None | str = '$UNCHANGED$', x_calib: bool | None | str = '$UNCHANGED$', y_calib: bool | None | str = '$UNCHANGED$') SklearnConformalSetPredictor[source]

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
  • alpha (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for alpha parameter in fit.

  • x_calib (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for x_calib parameter in fit.

  • y_calib (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for y_calib parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

Examples using probly.method.conformal.sklearn.SklearnConformalSetPredictor

Classification Conformal Prediction — sklearn

Classification Conformal Prediction — sklearn

Classification Conformal Prediction — PyTorch

Classification Conformal Prediction — PyTorch

Quantile Regression Conformal Prediction — sklearn

Quantile Regression Conformal Prediction — sklearn

Regression Conformal Prediction — sklearn

Regression Conformal Prediction — sklearn