Skip to content

Instantly share code, notes, and snippets.

@harrywang
Created May 4, 2021 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrywang/153a9b896b65570089ae1c4e5d8659ec to your computer and use it in GitHub Desktop.
Save harrywang/153a9b896b65570089ae1c4e5d8659ec to your computer and use it in GitHub Desktop.
sgd grid search example
# sgd regression pipeline with grid search
from sklearn.linear_model import SGDRegressor
from sklearn.model_selection import GridSearchCV
param_grid = [
{
'sgd_reg__max_iter':[100000, 1000000], # if number is too small, you will get a warning
'sgd_reg__tol':[1e-10, 1e-3],
'sgd_reg__eta0':[0.001, 0.01]
}
]
sgd_reg_pipeline = Pipeline(
steps=[
('preprocessor', preprocessor),
('sgd_reg', SGDRegressor()),
]
)
# sgd regression
sgd_grid_search = GridSearchCV(sgd_reg_pipeline, param_grid, cv=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment