Skip to content

Instantly share code, notes, and snippets.

@AayushSameerShah
Created September 6, 2021 07:16
Show Gist options
  • Save AayushSameerShah/c51e2d3ed6c4d8eeff9ad21c6d59448c to your computer and use it in GitHub Desktop.
Save AayushSameerShah/c51e2d3ed6c4d8eeff9ad21c6d59448c to your computer and use it in GitHub Desktop.
This will get correlation with the features and will return the correlated DF. Please update the column names.
def new_ft(operation):
ft = {}
for i in range(len(num_features)):
for j in range(i+1, len(num_features)):
ft1 = num_features[i]
ft2 = num_features[j]
oparated = eval(f"combined_xy[ft1] {operation} combined_xy[ft2]")
corr = oparated.corr(combined_xy["co2"])
ft[f"{ft1} {operation} {ft2}"] = corr
ser = pd.Series(ft)
return pd.concat([ser.rename("ORI"), ser.apply(abs).rename("ABS")], axis=1).sort_values(by="ABS", ascending=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment