Skip to content

Commit

Permalink
Revert "Make FrozenEstimator explicitly accept and ignore sample_weig…
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarManzoor authored Feb 26, 2025
1 parent a5e9504 commit 5eb676a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.

This file was deleted.

5 changes: 1 addition & 4 deletions sklearn/frozen/_frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __sklearn_is_fitted__(self):
except NotFittedError:
return False

def fit(self, X, y, sample_weight=None, *args, **kwargs):
def fit(self, X, y, *args, **kwargs):
"""No-op.
As a frozen estimator, calling `fit` has no effect.
Expand All @@ -99,9 +99,6 @@ def fit(self, X, y, sample_weight=None, *args, **kwargs):
y : object
Ignored.
sample_weight : object
Ignored.
*args : tuple
Additional positional arguments. Ignored, but present for API compatibility
with `self.estimator`.
Expand Down
15 changes: 1 addition & 14 deletions sklearn/frozen/tests/test_frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import RobustScaler, StandardScaler
from sklearn.utils._testing import set_random_state
from sklearn.utils.validation import check_is_fitted, has_fit_parameter
from sklearn.utils.validation import check_is_fitted


@pytest.fixture
Expand Down Expand Up @@ -221,16 +221,3 @@ def test_frozen_params():
other_est = LocalOutlierFactor()
frozen.set_params(estimator=other_est)
assert frozen.get_params() == {"estimator": other_est}


def test_frozen_ignores_sample_weight(regression_dataset):
X, y = regression_dataset
estimator = LinearRegression().fit(X, y)
frozen = FrozenEstimator(estimator)

# Should not raise: sample_weight is just ignored as it is not used.
frozen.fit(X, y, sample_weight=np.ones(len(y)))

# FrozenEstimator should have sample_weight in its signature to make it
# explicit that sample_weight is accepted and ignored intentionally.
assert has_fit_parameter(frozen, "sample_weight")

0 comments on commit 5eb676a

Please sign in to comment.