Partial Dependency Plots from AutoML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 02:19 PM
I have built an AutoML model, and I would like for it to add Partial Dependency Plots for the final/best model. I am trying to add this to the code generated, but not having any luck. This is the code I attempted.
from sklearn.inspection import PartialDependenceDisplay
# Create Partial Dependency Plots for each class
n_classes = len(model.classes_)
for target_class in range(n_classes):
target_label = model.classes_[target_class]
print(f"Partial dependency plots for class {target_label}:")
display = PartialDependenceDisplay.from_estimator(
model, X_train, np.arange(X_train.shape[1]), target=target_label
)
display.figure_.set_size_inches(12, 😎
display.figure_.suptitle(f"Partial dependency plots for class {target_label}")
plt.subplots_adjust(hspace=0.4, wspace=0.4)
plt.show()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 06:19 PM
@brandon.vaughn brandon.vaughn :
It looks like you are trying to use the PartialDependenceDisplay module from the sklearn.inspection module to create partial dependency plots for your AutoML model. Here are some suggestions to ensure that the code works:
- Make sure that you have imported all the necessary libraries, including matplotlib for plotting the partial dependency plots.
- Check that your 'model' variable is the final/best model from your AutoML model, and that it has the necessary attributes such as 'classes_' for multi-class classification.
- Ensure that your 'X_train' variable is the training data that was used to train your AutoML model. The partial dependency plots are based on the feature values in the training data.
- Verify that the shape of 'X_train' is compatible with the 'target' parameter in the PartialDependenceDisplay.from_estimator() function. The 'target' parameter specifies the class for which the partial dependency plots will be created, so it should be a valid index corresponding to the 'classes_' attribute of your model.
- Check that the matplotlib.pyplot library is imported and used correctly in the code. It should be used to create and display the partial dependency plots using the plt.subplots() and plt.show() functions.
If you have checked all of these factors and are still encountering issues, please provide more details about the specific error message or problem you are facing so that we can better assist you.

