Analyzing feature effects with beeswarm plots
Continuing your role as a data scientist at the university, you now shift focus to a more detailed analysis of individual feature effects on admissions outcomes. While identifying key factors influencing admissions decisions was crucial, delving deeper allows us to understand how variations in these factors specifically affect predictions. This additional insight will help answer questions like how changes in test scores or CGPA influence the likelihood of admission, providing a clearer picture for making informed decisions and policy recommendations.
The shap
library and the training data (X_train
, y_train
) have been pre-loaded for you.
This exercise is part of the course
Explainable AI in Python
Exercise instructions
- Derive the
shap_values
using aTreeExplainer
. - Use the derived
shap_values
to plot the beeswarm plot and analyze it.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
model = RandomForestRegressor(random_state=42)
model.fit(X_train, y_train)
# Derive shap values
explainer = ____
shap_values = ____
# Plot the beeswarm plot
____