from pdpbox import pdp
def plot_pdp(model, df, feature, cluster_flag=False, nb_clusters=None, lines_flag=False):
# Create the data that we will plot
pdp_goals = pdp.pdp_isolate(model=gbr_model, dataset=df_boston, model_features=df_boston.columns.tolist(), feature=feature)
# plot it
pdp.pdp_plot(pdp_goals, feature, cluster=cluster_flag, n_cluster_centers=nb_clusters, plot_lines=lines_flag)
####Parcial Dependancy Plot (PDP)
#@title Select a predictor to analyse Gradient Boosting Model. { run: "auto" }
selected_predictor = "log_crim" #@param ['log_crim','zn', 'indus', 'chas', 'nox', 'rm', 'log_age', 'log_dis', 'log_rad', 'tax', 'log_ptratio', 'lstat']
print('You selected', selected_predictor)
plot_pdp(gbr_model, X1_train, selected_predictor)