Skip to content

Instantly share code, notes, and snippets.

@harrywang
Created April 22, 2020 14:15
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/55b0776aa2cba6ac5fabccb06fcf3ef7 to your computer and use it in GitHub Desktop.
Save harrywang/55b0776aa2cba6ac5fabccb06fcf3ef7 to your computer and use it in GitHub Desktop.
Linear Regression Full Pipeline Code Snippet
### code snippet ####
from sklearn.linear_model import LinearRegression
lin_reg_full_pipeline = Pipeline(
steps=[
('preprocessor', preprocessor),
('lin_reg', LinearRegression()),
]
)
# use named_steps[] to access any step in your pipeline
lin_reg_full_pipeline.fit(X, y) # train the model using all training data
print(lin_reg_full_pipeline.named_steps['lin_reg'].intercept_, lin_reg_full_pipeline.named_steps['lin_reg'].coef_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment