8000 Revert "Make FrozenEstimator explicitly accept and ignore sample_weight" by OmarManzoor · Pull Request #30898 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Revert "Make FrozenEstimator explicitly accept and ignore sample_weight" #30898

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

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

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")
Loading
0