8000 Revert "Make FrozenEstimator explicitly accept and ignore sample_weig… · scikit-learn/scikit-learn@5eb676a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5eb676a

Browse files
authored
Revert "Make FrozenEstimator explicitly accept and ignore sample_weight" (#30898)
1 parent a5e9504 commit 5eb676a

File tree

3 files changed

+2
-21
lines changed

3 files changed

+2
-21
lines changed

doc/whats_new/upcoming_changes/sklearn.frozen/30874.enhancement.rst

-3
This file was deleted.

sklearn/frozen/_frozen.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __sklearn_is_fitted__(self):
8686
except NotFittedError:
8787
return False
8888

89-
def fit(self, X, y, sample_weight=None, *args, **kwargs):
89+
def fit(self, X, y, *args, **kwargs):
9090
"""No-op.
9191
9292
As a frozen estimator, calling `fit` has no effect.
@@ -99,9 +99,6 @@ def fit(self, X, y, sample_weight=None, *args, **kwargs):
9999
y : object
100100
Ignored.
101101
102-
sample_weight : object
103-
Ignored.
104-
105102
*args : tuple
106103
Additional positional arguments. Ignored, but present for API compatibility
107104
with `self.estimator`.

sklearn/frozen/tests/test_frozen.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from sklearn.pipeline import make_pipeline
2727
from sklearn.preprocessing import RobustScaler, StandardScaler
2828
from sklearn.utils._testing import set_random_state
29-
from sklearn.utils.validation import check_is_fitted, has_fit_parameter
29+
from sklearn.utils.validation import check_is_fitted
3030

3131

3232
@pytest.fixture
@@ -221,16 +221,3 @@ def test_frozen_params():
221221
other_est = LocalOutlierFactor()
222222
frozen.set_params(estimator=other_est)
223223
assert frozen.get_params() == {"estimator": other_est}
224-
225-
226-
def test_frozen_ignores_sample_weight(regression_dataset):
227-
X, y = regression_dataset
228-
estimator = LinearRegression().fit(X, y)
229-
frozen = FrozenEstimator(estimator)
230-
231-
# Should not raise: sample_weight is just ignored as it is not used.
232-
frozen.fit(X, y, sample_weight=np.ones(len(y)))
233-
234-
# FrozenEstimator should have sample_weight in its signature to make it
235-
# explicit that sample_weight is accepted and ignored intentionally.
236-
assert has_fit_parameter(frozen, "sample_weight")

0 commit comments

Comments
 (0)
0