Permutation importance

Pythonで学ぶExplainable AI

Fouad Trad

Machine Learning Engineer

音をシャッフルして楽器の重要度を測る

さまざまな楽器を演奏するバンドの画像。

Pythonで学ぶExplainable AI

Permutation importance

  • モデル非依存の手法
  • 特徴量の重要度を評価
    • 特徴量のシャッフルが性能に与える影響を測定
  • 高い汎用性

複数の隠れ層と多数のニューロンからなるニューラルネットの構造図。

Pythonで学ぶExplainable AI

Permutation importance の流れ

5つの特徴量と学習済みMLモデルのデータセットを示す図。

Pythonで学ぶExplainable AI

Permutation importance の流れ

データセットをMLモデルに入力してベースライン性能を得る図。

Pythonで学ぶExplainable AI

Permutation importance の流れ

元のデータでは特徴量の値が [1, 2, 3, 4]、シャッフル後は [4, 2, 1, 3]。このシャッフル済みデータをMLモデルに入力してシャッフル後の性能を得る図。

Pythonで学ぶExplainable AI

Permutation importance の流れ

シャッフルした特徴量の重要度は性能低下に比例することを示す図。

Pythonで学ぶExplainable AI

Permutation importance の流れ

性能の大きな低下はその特徴量の重要度が高いことを、小さな低下は重要度が低いことを示す図。

Pythonで学ぶExplainable AI

入学判定データセット

GRE Score TOEFL Score University Rating SOP LOR CGPA Chance of Admit Accept
337 118 4 4.5 4.5 9.65 0.92 1
324 107 4 4 4.5 8.87 0.76 1
316 104 3 3 3.5 8 0.72 1
322 110 3 3.5 2.5 8.67 0.8 1
314 103 2 2 3 8.21 0.45 0

 

データは次にあります: X_train, y_train

Pythonで学ぶExplainable AI

MLPClassifier

from sklearn.neural_network import MLPClassifier
model = MLPClassifier(hidden_layer_sizes=(10,10))

model.fit(X_train, y_train)
Pythonで学ぶExplainable AI

Permutation importance

from sklearn.inspection import permutation_importance

result = permutation_importance(model,
X_train, y_train,
n_repeats=10,
random_state=42,
scoring='accuracy')
print(result.importances_mean)
[0.16213568 0.13831658 0.10575377 0.10522613 0.11741206 0.20072864]
Pythonで学ぶExplainable AI

重要度の可視化

import matplotlib.pyplot as plt
plt.bar(X_train.columns,
        result.importances_mean)

Permutation importance の棒グラフ。CGPA が最も高い重要度を示す。

Pythonで学ぶExplainable AI

モデル固有手法との比較

import matplotlib.pyplot as plt
plt.bar(X_train.columns, 
        result.importances_mean)

Permutation importance の棒グラフ。CGPA が最も高い重要度を示す。

ロジスティック回帰
plt.bar(X_train.columns, np.abs(log_reg.coef_[0]))

ロジスティック回帰の係数の棒グラフ。CGPA が最も高い重要度を示す。

Pythonで学ぶExplainable AI

Passons à la pratique !

Pythonで学ぶExplainable AI

Preparing Video For Download...