Skip to content

Commit 767d355

Browse files
authored
MAINT Clean up deprecated base_estimator in RANSAC for 1.3 (scikit-learn#26481)
1 parent b0e4630 commit 767d355

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

sklearn/linear_model/_ransac.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..utils.validation import check_is_fitted, _check_sample_weight
1515
from ._base import LinearRegression
1616
from ..utils.validation import has_fit_parameter
17-
from ..utils._param_validation import Interval, Options, StrOptions, HasMethods, Hidden
17+
from ..utils._param_validation import Interval, Options, StrOptions, HasMethods
1818
from ..utils._param_validation import RealNotInt
1919
from ..exceptions import ConvergenceWarning
2020

@@ -161,13 +161,6 @@ class RANSACRegressor(
161161
Pass an int for reproducible output across multiple function calls.
162162
See :term:`Glossary <random_state>`.
163163
164-
base_estimator : object, default="deprecated"
165-
Use `estimator` instead.
166-
167-
.. deprecated:: 1.1
168-
`base_estimator` is deprecated and will be removed in 1.3.
169-
Use `estimator` instead.
170-
171164
Attributes
172165
----------
173166
estimator_ : object
@@ -259,11 +252,6 @@ class RANSACRegressor(
259252
"stop_probability": [Interval(Real, 0, 1, closed="both")],
260253
"loss": [StrOptions({"absolute_error", "squared_error"}), callable],
261254
"random_state": ["random_state"],
262-
"base_estimator": [
263-
HasMethods(["fit", "score", "predict"]),
264-
Hidden(StrOptions({"deprecated"})),
265-
None,
266-
],
267255
}
268256

269257
def __init__(
@@ -281,7 +269,6 @@ def __init__(
281269
stop_probability=0.99,
282270
loss="absolute_error",
283271
random_state=None,
284-
base_estimator="deprecated",
285272
):
286273
self.estimator = estimator
287274
self.min_samples = min_samples
@@ -295,7 +282,6 @@ def __init__(
295282
self.stop_probability = stop_probability
296283
self.random_state = random_state
297284
self.loss = loss
298-
self.base_estimator = base_estimator
299285

300286
def fit(self, X, y, sample_weight=None):
301287
"""Fit estimator using RANSAC algorithm.
@@ -339,16 +325,6 @@ def fit(self, X, y, sample_weight=None):
339325
)
340326
check_consistent_length(X, y)
341327

342-
if self.base_estimator != "deprecated":
343-
warnings.warn(
344-
(
345-
"`base_estimator` was renamed to `estimator` in version 1.1 and "
346-
"will be removed in 1.3."
347-
),
348-
FutureWarning,
349-
)
350-
self.estimator = self.base_estimator
351-
352328
if self.estimator is not None:
353329
estimator = clone(self.estimator)
354330
else:

sklearn/linear_model/tests/test_ransac.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -569,18 +569,3 @@ def test_perfect_horizontal_line():
569569

570570
assert_allclose(ransac_estimator.estimator_.coef_, 0.0)
571571
assert_allclose(ransac_estimator.estimator_.intercept_, 0.0)
572-
573-
574-
def test_base_estimator_deprecated():
575-
ransac_estimator = RANSACRegressor(
576-
base_estimator=LinearRegression(),
577-
min_samples=2,
578-
residual_threshold=5,
579-
random_state=0,
580-
)
581-
err_msg = (
582-
"`base_estimator` was renamed to `estimator` in version 1.1 and "
583-
"will be removed in 1.3."
584-
)
585-
with pytest.warns(FutureWarning, match=err_msg):
586-
ransac_estimator.fit(X, y)

0 commit comments

Comments
 (0)