daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Jun 21st, 2018 54 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. # Threshold for removing correlated variables
  2. threshold = 0.9
  3.  
  4. # Absolute value correlation matrix
  5. corr_matrix = app.corr().abs()
  6.  
  7. # Upper triangle of correlations
  8. upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))
  9.  
  10. # Select columns with correlations above threshold
  11. to_drop = [column for column in upper.columns if any(upper[column] > threshold)]
  12.  
  13. # Remove the columns
  14. app = app.drop(columns = to_drop)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top