Skip to content

Instantly share code, notes, and snippets.

@vikramsoni2
Created April 16, 2019 14:57
Show Gist options
  • Save vikramsoni2/a43e18046e703cf0565bb9dd3430d1b1 to your computer and use it in GitHub Desktop.
Save vikramsoni2/a43e18046e703cf0565bb9dd3430d1b1 to your computer and use it in GitHub Desktop.
remove highly linearly correlated feature
corr_matrix = all_data.corr().abs()
upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))
to_drop = [c for c in upper.columns if any(upper[c] > 0.95)]
del upper
drop_column = all_data.columns[to_drop]
print('drop columns:', drop_column)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment