高相関の特徴量を除去する

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...