Created
August 5, 2020 10:10
-
-
Save netsatsawat/f00f3eaeca714be9e3e0a32a51cf33db to your computer and use it in GitHub Desktop.
Snippet of SGD regressor implementation using sklearn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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