scikit-learn-contrib/lightning

Forgotten intercept in SGDRegressor

StrikerRUS opened this issue · 2 comments

Hey guys!

Seems that there is a bug in the predict method of SGDRegressor.

Shouldn't intercept_ be added here?

try:
assert_all_finite(self.coef_)
pred = safe_sparse_dot(X, self.coef_.T)
except ValueError:
n_samples = X.shape[0]
n_vectors = self.coef_.shape[0]
pred = np.zeros((n_samples, n_vectors))
if not self.outputs_2d_:
pred = pred.ravel()
return pred

cf.
def predict(self, X):
pred = safe_sparse_dot(X, self.coef_.T)
if hasattr(self, "intercept_"):
pred += self.intercept_

Yep, I think you're right. Thanks for the catch.