Created
July 12, 2018 01:11
-
-
Save securetorobert/ef48bcacac6176d014bb8a475e77efa1 to your computer and use it in GitHub Desktop.
Polynomial features with lasso regression on Boston housing data
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
steps = [ | |
('scalar', StandardScaler()), | |
('poly', PolynomialFeatures(degree=2)), | |
('model', Lasso(alpha=0.3, fit_intercept=True)) | |
] | |
lasso_pipe = Pipeline(steps) | |
lasso_pipe.fit(X_train, y_train) | |
print('Training score: {}'.format(lasso_pipe.score(X_train, y_train))) | |
print('Test score: {}'.format(lasso_pipe.score(X_test, y_test))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment