Skip to content

Commit 380946d

Browse files
ENH: V1 CQR docstrings (#577)
ENH: V1 CQR docstrings
1 parent 02a652e commit 380946d

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

mapie_v1/regression.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -834,43 +834,54 @@ def predict(
834834

835835
class ConformalizedQuantileRegressor:
836836
"""
837-
A conformal quantile regression model that generates prediction intervals
838-
using quantile regression as the base estimator.
837+
A model that combines quantile regression with conformal prediction to
838+
generate reliable prediction intervals with specified coverage levels.
839839
840-
This approach provides prediction intervals by leveraging
841-
quantile predictions and applying conformal adjustments to ensure coverage.
840+
The `ConformalizedQuantileRegressor` leverages quantile regression as its
841+
base estimator to predict conditional quantiles of the target variable,
842+
and applies conformal adjustments to ensure prediction intervals achieve
843+
the desired confidence levels. This approach is particularly useful in
844+
uncertainty quantification for regression tasks.
842845
843846
Parameters
844847
----------
845-
estimator : RegressorMixin, default=QuantileRegressor()
846-
The base quantile regression estimator used to generate point and
847-
interval predictions.
848-
849-
confidence_level : Union[float, List[float]], default=0.9
848+
estimator : Union[`RegressorMixin`, `Pipeline`, \
849+
`List[Union[RegressorMixin, Pipeline]]`]
850+
The base quantile regression model(s) for estimating target quantiles.
851+
852+
- When `prefit=False` (default):
853+
A single quantile regression estimator (e.g., `QuantileRegressor`)
854+
or a pipeline that combines preprocessing and regression.
855+
Supported Regression estimators:
856+
857+
- ``sklearn.linear_model.QuantileRegressor``
858+
- ``sklearn.ensemble.GradientBoostingRegressor``
859+
- ``sklearn.ensemble.HistGradientBoostingRegressor``
860+
- ``lightgbm.LGBMRegressor``
861+
862+
- When `prefit=True`:
863+
A list of three fitted quantile regression estimators corresponding
864+
to lower, upper, and median quantiles. These estimators should be
865+
pre-trained with consistent quantile settings:
866+
867+
* ``lower quantile = 1 - confidence_level / 2``
868+
* ``upper quantile = confidence_level / 2``
869+
* ``median quantile = 0.5``
870+
871+
confidence_level : float default=0.9
850872
The confidence level(s) for the prediction intervals, indicating the
851-
desired coverage probability of the prediction intervals. If a float
852-
is provided, it represents a single confidence level. If a list,
853-
multiple prediction intervals for each specified confidence level
854-
are returned.
855-
856-
conformity_score : Union[str, BaseRegressionScore], default="absolute"
857-
The conformity score method used to calculate the conformity error.
858-
Valid options: TODO : reference here the valid options, once the list
859-
has been be created during the implementation.
860-
See: TODO : reference conformity score classes or documentation
861-
862-
A custom score function inheriting from BaseRegressionScore may also
863-
be provided.
873+
desired coverage probability of the prediction intervals.
864874
865-
random_state : Optional[Union[int, np.random.RandomState]], default=None
866-
A seed or random state instance to ensure reproducibility in any random
867-
operations within the regressor.
875+
prefit : bool, default=False
876+
If `True`, assumes the base estimators are already fitted.
877+
When set to `True`, the `fit` method cannot be called and the
878+
provided estimators should be pre-trained.
868879
869880
Methods
870881
-------
871882
fit(X_train, y_train, fit_params=None) -> Self
872-
Fits the base estimator to the training data and initializes internal
873-
parameters required for conformal prediction.
883+
Trains the base quantile regression estimator on the provided data.
884+
Not applicable if `prefit=True`.
874885
875886
conformalize(X_conf, y_conf, predict_params=None) -> Self
876887
Calibrates the model on provided data, adjusting the prediction
@@ -987,7 +998,7 @@ def conformalize(
987998
"""
988999
Calibrates the model on the provided data, adjusting the prediction
9891000
intervals based on quantile predictions and specified confidence
990-
levels. This step analyzes the conformity scores and refines the
1001+
level. This step analyzes the conformity scores and refines the
9911002
intervals to ensure desired coverage.
9921003
9931004
Parameters

0 commit comments

Comments
 (0)