Skip to content

Instantly share code, notes, and snippets.

@securetorobert
Created July 12, 2018 00:56
Show Gist options
  • Save securetorobert/8134a7511718542e8ef93be1c9c1acf0 to your computer and use it in GitHub Desktop.
Save securetorobert/8134a7511718542e8ef93be1c9c1acf0 to your computer and use it in GitHub Desktop.
Create polynomial features on a linear regression model for Boston housing data
steps = [
('scalar', StandardScaler()),
('poly', PolynomialFeatures(degree=2)),
('model', LinearRegression())
]
pipeline = Pipeline(steps)
pipeline.fit(X_train, y_train)
print('Training score: {}'.format(pipeline.score(X_train, y_train)))
print('Test score: {}'.format(pipeline.score(X_test, y_test)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment