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
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- non_conformity_score¶
- 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
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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
alphaparameter infit.x_calib (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
x_calibparameter infit.y_calib (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_calibparameter infit.
- Returns:
self – The updated object.
- Return type:
- 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¶
Quantile Regression Conformal Prediction — sklearn