📜  scikit 学习识别高度相关的特征 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:04.805000             🧑  作者: Mango

代码示例2
# 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)]