Permutation importance for MLPClassifier
Your task is to use permutation importance to identify which features are most impactful in predicting heart disease with an MLPClassifier.
X
containing the features and y
containing the labels have been pre-loaded for you. matplotlib.pyplot
has been imported as plt
.
This exercise is part of the course
Explainable AI in Python
Exercise instructions
- Compute the permutation importance with 10 repeats using a
random_state
of 1. - Plot feature importances with a bar plot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
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()