From d700b707063b9e1b782e7a805908d6837741102c Mon Sep 17 00:00:00 2001 From: Valentin Laurent Date: Tue, 14 Jan 2025 14:31:23 +0100 Subject: [PATCH] ENH: remove random_state from API when actually not used --- doc/v1_migration_guide.rst | 6 ++++++ mapie_v1/integration_tests/tests/test_regression.py | 10 +--------- mapie_v1/regression.py | 6 ------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/doc/v1_migration_guide.rst b/doc/v1_migration_guide.rst index ca93b227a..26582c285 100644 --- a/doc/v1_migration_guide.rst +++ b/doc/v1_migration_guide.rst @@ -130,6 +130,12 @@ The aggregation method and technique for combining predictions in ensemble metho - **v0.9**: Previously, the ``agg_function`` parameter had two usage: to aggregate predictions when setting ``ensemble=True`` in the ``predict`` method, and to specify the aggregation technique in ``JackknifeAfterBootstrapRegressor``. - **v1**: The ``agg_function`` parameter has been split into two distinct parameters: ``aggregate_predictions`` and ``aggregation_method``. ``aggregate_predictions`` is specific to ``CrossConformalRegressor``, and it specifies how predictions from multiple conformal regressors are aggregated when making point predictions. ``aggregation_method`` is specific to ``JackknifeAfterBootstrapRegressor``, and it specifies the aggregation technique for combining predictions across different bootstrap samples during conformalization. +``random_state`` +~~~~~~~~~~~~~~~~~~ + +- **v0.9**: This parameter was used to control the randomness of the data splitting. +- **v1**: This parameter has been removed in cases where data splitting is now manual. Future evolutions may reintroduce it as a general purpose randomness control parameter. + ``Other parameters`` ~~~~~~~~~~~~~~~~~~~~ No more parameters with incorrect ``None`` defaults. diff --git a/mapie_v1/integration_tests/tests/test_regression.py b/mapie_v1/integration_tests/tests/test_regression.py index 304429c09..1ad7de845 100644 --- a/mapie_v1/integration_tests/tests/test_regression.py +++ b/mapie_v1/integration_tests/tests/test_regression.py @@ -71,7 +71,6 @@ "prefit": False, "test_size": 0.4, "fit_params": {"sample_weight": sample_weight_train}, - "random_state": RANDOM_STATE, } }, { @@ -89,7 +88,6 @@ "confidence_level": [0.5, 0.5], "conformity_score": "gamma", "prefit": False, - "random_state": RANDOM_STATE, } }, { @@ -113,7 +111,6 @@ random_state=RANDOM_STATE ), "allow_infinite_bounds": True, - "random_state": RANDOM_STATE, } }, { @@ -130,7 +127,6 @@ "estimator": positive_predictor, "confidence_level": 0.9, "conformity_score": GammaConformityScore(), - "random_state": RANDOM_STATE, "test_size": 0.3, "minimize_interval_width": True } @@ -358,7 +354,6 @@ def test_intervals_and_predictions_exact_equality_jackknife(params_jackknife): "prefit": False, "test_size": 0.4, "fit_params": {"sample_weight": sample_weight_train}, - "random_state": RANDOM_STATE, }, }, { @@ -379,7 +374,6 @@ def test_intervals_and_predictions_exact_equality_jackknife(params_jackknife): "test_size": 0.2, "fit_params": {"sample_weight": sample_weight}, "minimize_interval_width": True, - "random_state": RANDOM_STATE, }, }, { @@ -398,7 +392,6 @@ def test_intervals_and_predictions_exact_equality_jackknife(params_jackknife): "prefit": False, "test_size": 0.3, "allow_infinite_bounds": True, - "random_state": RANDOM_STATE, }, }, { @@ -414,7 +407,6 @@ def test_intervals_and_predictions_exact_equality_jackknife(params_jackknife): "confidence_level": 0.9, "prefit": False, "test_size": 0.3, - "random_state": RANDOM_STATE, "symmetric_intervals": False, }, }, @@ -457,7 +449,7 @@ def compare_model_predictions_and_intervals( prefit: bool = False, test_size: Optional[float] = None, sample_weight: Optional[ArrayLike] = None, - random_state: int = 42, + random_state: int = RANDOM_STATE, ) -> None: if test_size is not None: diff --git a/mapie_v1/regression.py b/mapie_v1/regression.py index 8816714dc..fbc9191dd 100644 --- a/mapie_v1/regression.py +++ b/mapie_v1/regression.py @@ -62,10 +62,6 @@ class SplitConformalRegressor: Controls the verbosity level. Higher values increase the output details. - 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. - Notes ----- This implementation currently uses a ShuffleSplit cross-validation scheme @@ -100,7 +96,6 @@ def __init__( prefit: bool = False, n_jobs: Optional[int] = None, verbose: int = 0, - random_state: Optional[Union[int, np.random.RandomState]] = None, ) -> None: check_estimator_fit_predict(estimator) self._estimator = estimator @@ -118,7 +113,6 @@ def __init__( n_jobs=n_jobs, verbose=verbose, conformity_score=self._conformity_score, - random_state=random_state, ) self._alphas = transform_confidence_level_to_alpha_list(