Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

scikit learn to identify highly correlated features

# Create correlation matrix
corr_matrix = df.corr().abs()

# Select upper triangle of correlation matrix
upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))

# Find index of feature columns with correlation greater than 0.95
to_drop = [column for column in upper.columns if any(upper[column] > 0.95)]
Comment

PREVIOUS NEXT
Code Example
Python :: append 1 colimn in pandas df 
Python :: raise_for_status() requests 
Python :: python loop index and value 
Python :: csv read python 
Python :: python create random mac 
Python :: how to print during multiprocessing 
Python :: how to convert string to integer in python 
Python :: matrix diagonal sum leetcode in Python 
Python :: append in python 
Python :: pytorch squeeze 
Python :: django email change sender name 
Python :: argparse accept only few options 
Python :: torch print full tensor 
Python :: binary to decimal in python without inbuilt function 
Python :: python boolean operators 
Python :: python curses for windows 
Python :: python A string float numeral into integer 
Python :: python web framework 
Python :: django from 
Python :: python check if key exist in json 
Python :: defaultdict python 
Python :: brute force string matching algorithm in python 
Python :: get first element of array python 
Python :: from django.core.management import execute_from_command_line ImportError: No module named django.core.management 
Python :: Get more than one longest word in a list python 
Python :: pass 2d array to 1d python 
Python :: for loop with index python 
Python :: arange float step 
Python :: while not command in python 
Python :: Progress Bars in Python 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =