시작하기무료로 시작하기

MLPClassifier를 위한 Permutation importance

여러분의 과제는 permutation importance를 사용해 MLPClassifier로 심장 질환을 예측할 때 어떤 특징이 가장 큰 영향을 미치는지 파악하는 거예요.

특징을 담은 X와 레이블을 담은 y는 이미 로드되어 있어요. matplotlib.pyplotplt로 임포트되어 있어요.

이 연습은 강의의 일부입니다

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()
코드 편집 및 실행