8000 ENH Removes validation from __init__ for SGDOneClassSVM by iofall · Pull Request #21944 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

ENH Removes validation from __init__ for SGDOneClassSVM #21944

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

Closed
wants to merge 5 commits into from
Closed
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
5 changes: 5 additions & 0 deletions doc/whats_new/v1.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ Changelog
:pr:`21481` by :user:`Guillaume Lemaitre <glemaitre>` and
:user:`Andrés Babino <ababino>`.

- |Fix| :class:`linear_model.SGDOneClassSVM` now does not validate in
`__init__`. All the validation is now handled through `fit()` and
`partial_fit()`.
:pr:`21944` by :user:`Yogendrasingh <iofall>` and :user: `Arisa Y. <arisayosh>`

:mod:`sklearn.metrics`
......................

Expand Down
6 changes: 3 additions & 3 deletions sklearn/linear_model/_stochastic_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ def __init__(
average=False,
):

alpha = nu / 2
alpha = None
self.nu = nu
super(SGDOneClassSVM, self).__init__(
loss="hinge",
Expand Down Expand Up @@ -2305,8 +2305,8 @@ def partial_fit(self, X, y=None, sample_weight=None):
Returns a fitted instance of self.
"""

alpha = self.nu / 2
self._validate_params(for_partial_fit=True)
alpha = self.nu / 2

return self._partial_fit(
X,
Expand All @@ -2331,7 +2331,6 @@ def _fit(
offset_init=None,
sample_weight=None,
):
self._validate_params()

if self.warm_start and hasattr(self, "coef_"):
if coef_init is None:
Expand Down Expand Up @@ -2404,6 +2403,7 @@ def fit(self, X, y=None, coef_init=None, offset_init=None, sample_weight=None):
Returns a fitted instance of self.
"""

self._validate_params()
alpha = self.nu / 2
self._fit(
X,
Expand Down
1 change: 0 additions & 1 deletion sklearn/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ def test_transformers_get_feature_names_out(transformer):
"FeatureUnion",
"GridSearchCV",
"HalvingGridSearchCV",
"SGDOneClassSVM",
"TheilSenRegressor",
"TweedieRegressor",
]
Expand Down
0