Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4fc2376

Browse filesBrowse files
committed
fix self.alpha modified in fit
1 parent 37c71dc commit 4fc2376
Copy full SHA for 4fc2376

File tree

1 file changed

+5
-5
lines changed
Filter options

1 file changed

+5
-5
lines changed

‎sklearn/linear_model/stochastic_gradient.py

Copy file name to clipboardExpand all lines: sklearn/linear_model/stochastic_gradient.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _validate_params(self, set_max_iter=True):
9292
raise ValueError("max_iter must be > zero. Got %f" % self.max_iter)
9393
if not (0.0 <= self.l1_ratio <= 1.0):
9494
raise ValueError("l1_ratio must be in [0, 1]")
95-
if self.alpha < 0.0:
95+
if not isinstance(self, SGDOneClassSVM) and self.alpha < 0.0:
9696
raise ValueError("alpha must be >= 0")
9797
if self.learning_rate in ("constant", "invscaling"):
9898
if self.eta0 <= 0.0:
@@ -1611,10 +1611,10 @@ def partial_fit(self, X, y=None, sample_weight=None):
16111611
self : returns an instance of self.
16121612
"""
16131613

1614-
self.alpha = self.nu / 2
1614+
alpha = self.nu / 2
16151615
self._validate_params()
16161616

1617-
return self._partial_fit(X, self.alpha, C=1.0, loss=self.loss,
1617+
return self._partial_fit(X, alpha, C=1.0, loss=self.loss,
16181618
learning_rate=self.learning_rate,
16191619
max_iter=1,
16201620
sample_weight=sample_weight,
@@ -1688,8 +1688,8 @@ def fit(self, X, y=None, coef_init=None, offset_init=None,
16881688
self : returns an instance of self.
16891689
"""
16901690

1691-
self.alpha = self.nu / 2
1692-
self._fit(X, alpha=self.alpha, C=1.0,
1691+
alpha = self.nu / 2
1692+
self._fit(X, alpha=alpha, C=1.0,
16931693
loss=self.loss, learning_rate=self.learning_rate,
16941694
coef_init=coef_init, offset_init=offset_init,
16951695
sample_weight=sample_weight)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.