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()