From c6772d64cabbecbb2fb0614142a2dd6f4e81523d Mon Sep 17 00:00:00 2001 From: jawadhussein462 Date: Thu, 19 Dec 2024 16:08:14 +0100 Subject: [PATCH] EHC: V1 CQR improve docstrings --- mapie_v1/regression.py | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/mapie_v1/regression.py b/mapie_v1/regression.py index 4e2de7844..62967e8f6 100644 --- a/mapie_v1/regression.py +++ b/mapie_v1/regression.py @@ -834,43 +834,43 @@ def predict( class ConformalizedQuantileRegressor: """ - A conformal quantile regression model that generates prediction intervals - using quantile regression as the base estimator. + A model that combines quantile regression with conformal prediction to + generate reliable prediction intervals with specified coverage levels. - This approach provides prediction intervals by leveraging - quantile predictions and applying conformal adjustments to ensure coverage. + The `ConformalizedQuantileRegressor` leverages quantile regression as its + base estimator to predict conditional quantiles of the target variable, + and applies conformal adjustments to ensure prediction intervals achieve + the desired confidence levels. This approach is particularly useful in + uncertainty quantification for regression tasks. Parameters ---------- - estimator : RegressorMixin, default=QuantileRegressor() - The base quantile regression estimator used to generate point and - interval predictions. - - confidence_level : Union[float, List[float]], default=0.9 + estimator : Union[RegressorMixin, Pipeline, + List[Union[RegressorMixin, Pipeline]]] + The base quantile regression model(s) used to estimate the target + quantiles. + - In `fit` mode (`prefit=False`), this should be a single quantile + regression estimator (e.g., `QuantileRegressor`) or a pipeline + combining preprocessing and regression. + - In `prefit` mode (`prefit=True`), this must be a list of three + fitted quantile regression estimators, corresponding to the lower, + upper, and median quantiles. These models are expected to be + pre-trained and aligned with the target quantiles. + + confidence_level : float default=0.9 The confidence level(s) for the prediction intervals, indicating the - desired coverage probability of the prediction intervals. If a float - is provided, it represents a single confidence level. If a list, - multiple prediction intervals for each specified confidence level - are returned. - - conformity_score : Union[str, BaseRegressionScore], default="absolute" - The conformity score method used to calculate the conformity error. - Valid options: TODO : reference here the valid options, once the list - has been be created during the implementation. - See: TODO : reference conformity score classes or documentation - - A custom score function inheriting from BaseRegressionScore may also - be provided. + desired coverage probability of the prediction intervals. - random_state : Optional[Union[int, np.random.RandomState]], default=None - A seed or random state instance to ensure reproducibility in any random - operations within the regressor. + prefit : bool, default=False + If `True`, assumes the base estimators are already fitted. + When set to `True`, the `fit` method cannot be called and the + provided estimators should be pre-trained. Methods ------- fit(X_train, y_train, fit_params=None) -> Self - Fits the base estimator to the training data and initializes internal - parameters required for conformal prediction. + Trains the base quantile regression estimator on the provided data. + Not applicable if `prefit=True`. conformalize(X_conf, y_conf, predict_params=None) -> Self Calibrates the model on provided data, adjusting the prediction @@ -987,7 +987,7 @@ def conformalize( """ Calibrates the model on the provided data, adjusting the prediction intervals based on quantile predictions and specified confidence - levels. This step analyzes the conformity scores and refines the + level. This step analyzes the conformity scores and refines the intervals to ensure desired coverage. Parameters