Finding key heart disease predictors with SHAP
Your task is to use SHAP to understand how different features in a pre-trained RandomForestClassifier model influence predictions for heart disease.
X containing the features and y containing the labels, and the random forest classifier model have been pre-loaded for you.
Latihan ini adalah bagian dari kursus
Explainable AI in Python
Petunjuk latihan
- Create a SHAP tree explainer named
explainer. - Compute
shap_values. - Compute the mean absolute SHAP values
mean_abs_shap.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
import shap
# Create a SHAP Tree Explainer
explainer = ____
# Calculate SHAP values
shap_values = ____
# Calculate mean absolute SHAP values
mean_abs_shap = ____
plt.bar(X.columns, mean_abs_shap)
plt.title('Mean Absolute SHAP Values for RandomForest')
plt.xticks(rotation=45)
plt.show()