Skip to content

Instantly share code, notes, and snippets.

@joseph-allen
Created April 17, 2019 12:26
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 joseph-allen/5dd381f11a5f286d44d0fd4c954f9296 to your computer and use it in GitHub Desktop.
Save joseph-allen/5dd381f11a5f286d44d0fd4c954f9296 to your computer and use it in GitHub Desktop.
generates polynomial features out of any
from sklearn.preprocessing import PolynomialFeatures
p = PolynomialFeatures(degree=2).fit(df[['feature1','feature2]])
features = pd.DataFrame(p.transform(df[['feature1','feature2]]), columns=p.get_feature_names(df[['feature1','feature2]].columns))
features.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment