Skip to content

Instantly share code, notes, and snippets.

@rkdgusrn1212
Last active May 27, 2022 16:55
Show Gist options
  • Save rkdgusrn1212/8186976b422a8a37504ac378770248f4 to your computer and use it in GitHub Desktop.
Save rkdgusrn1212/8186976b422a8a37504ac378770248f4 to your computer and use it in GitHub Desktop.
Partial Dependence Plot
from matplotlib import pyplot as plt
from pdpbox import pdp
#my_model, val_X, feature_list
# isolate pdp
pdp_iso = pdp.pdp_isolate(model=my_model, dataset=val_X, model_features=feature_list, feature='feature1')
pdp.pdp_plot(pdp_iso, 'feature1')
plt.show()
# interact pdp
pdp_inter = pdp.pdp_interact(model=my_model, dataset=val_X, model_features=feature_list, features=['feature1', 'feature2'])
pdp.pdp_interact_plot(pdp_interact_out=pdp_inter, feature_names=['feature1', 'feature2'], plot_type='contour')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment