Skip to content

Instantly share code, notes, and snippets.

@netsatsawat
Created August 5, 2020 10:10
Show Gist options
  • Save netsatsawat/f00f3eaeca714be9e3e0a32a51cf33db to your computer and use it in GitHub Desktop.
Save netsatsawat/f00f3eaeca714be9e3e0a32a51cf33db to your computer and use it in GitHub Desktop.
Snippet of SGD regressor implementation using sklearn
from sklearn.linear_model import SGDRegressor
SGD_rgs_normal = SGDRegressor(fit_intercept=True, random_state=SEED, eta0=learning_rate,
learning_rate='constant', max_iter=n_epochs)
SGD_rgs_normal.fit(X, y)
print(SGD_rgs_normal)
print(f'Intercept: {SGD_rgs_normal.intercept_}, weights: {SGD_rgs_normal.coef_}')
y_pred = SGD_rgs_normal.predict(X)
_ = print_regress_metric(y, y_pred)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment