Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: remove random_state from API when actually not used #599

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/v1_migration_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 1 addition & 9 deletions mapie_v1/integration_tests/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"prefit": False,
"test_size": 0.4,
"fit_params": {"sample_weight": sample_weight_train},
"random_state": RANDOM_STATE,
}
},
{
Expand All @@ -89,7 +88,6 @@
"confidence_level": [0.5, 0.5],
"conformity_score": "gamma",
"prefit": False,
"random_state": RANDOM_STATE,
}
},
{
Expand All @@ -113,7 +111,6 @@
random_state=RANDOM_STATE
),
"allow_infinite_bounds": True,
"random_state": RANDOM_STATE,
}
},
{
Expand All @@ -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
}
Expand Down Expand Up @@ -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,
},
},
{
Expand All @@ -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,
},
},
{
Expand All @@ -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,
},
},
{
Expand All @@ -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,
},
},
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions mapie_v1/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
Loading