A partial dependence function shows how a model's prediction depends on one or two features after averaging over the others:
i.e. for each grid value, set the chosen feature(s) of every training row to that value, predict, and average.
Implement:
partial_dependence(predict_fn, X, k, grid, log_odds=False): returns an array with one value per grid point. predict_fn maps an (n, D) array to (n,) predictions. With log_odds=True, the predictions are probabilities in ; convert each to before averaging.partial_dependence_2d(predict_fn, X, j, k, grid_j, grid_k, log_odds=False): returns a (len(grid_j), len(grid_k)) array whose entry uses = grid_j[a] and = grid_k[b].Never modify X in place.