移除高度相关的特征

Python 中的降维

Jeroen Boeye

Head of Machine Learning, Faktion

高度相关的数据

高度相关的配对图

Python 中的降维

高度相关的特征

高度相关的矩阵

Python 中的降维

移除高度相关的特征

# Create positive correlation matrix
corr_df = chest_df.corr().abs()

# Create and apply mask mask = np.triu(np.ones_like(corr_df, dtype=bool))
tri_df = corr_df.mask(mask) tri_df

Python 中的降维

移除高度相关的特征

# Find columns that meet threshold 
to_drop = [c for c in tri_df.columns if any(tri_df[c] > 0.95)]

print(to_drop)
['Suprasternale height', 'Cervicale height']
# Drop those columns
reduced_df = chest_df.drop(to_drop, axis=1)
Python 中的降维

特征选择

特征选择示意图

特征提取

特征提取示意图

Python 中的降维

相关性的注意事项——安斯库姆四重奏

安斯库姆四重奏

Python 中的降维

相关性的注意事项——因果关系

sns.scatterplot(x="N firetrucks sent to fire", 
                y="N wounded by fire",data=fire_df)

消防车数 vs. 火灾伤者数

Python 中的降维

开始练习!

Python 中的降维

Preparing Video For Download...