MLPClassifier の Permutation importance
あなたのタスクは、Permutation importance を使って、MLPClassifier による心疾患予測でどの特徴量が最も影響力が大きいかを特定することです。
特徴量を含む X とラベルを含む y はあらかじめ読み込まれています。matplotlib.pyplot は plt としてインポート済みです。
この演習はコースの一部です
Pythonで学ぶExplainable AI
演習の手順
random_stateを 1 にして、10 回の繰り返しで Permutation importance を計算します。- 棒グラフで特徴量重要度をプロットします。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
from sklearn.neural_network import MLPClassifier
from sklearn.inspection import permutation_importance
model = MLPClassifier(hidden_layer_sizes=(10), random_state=1)
model.fit(X, y)
# Compute the permutation importance
result = ____
# Plot feature importances
____
plt.xticks(rotation=45)
plt.show()