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.
Bu egzersiz
Explainable AI in Python
kursunun bir parçasıdırEgzersiz talimatları
- Create a SHAP tree explainer named
explainer. - Compute
shap_values. - Compute the mean absolute SHAP values
mean_abs_shap.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
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()