code: def partial_dependence(
      gbrt,
      target_variables,
      grid=None,
      X=None,
      percentiles=(0.05, 0.95),
      grid_resolution=100,
  ):
      """Partial dependence of ``target_variables``.
  
      Partial dependence plots show the dependence between the joint values
      of the ``target_variables`` and the function represented
      by the ``gbrt``.
  
      Read more in the :ref:`User Guide <partial_dependence>`.
  
      Parameters
      ----------
      gbrt : BaseGradientBoosting
          A fitted gradient boosting model.
      target_variables : array-like, dtype=int
          The target features for which the partial dependecy should be
          computed (size should be smaller than 3 for visual renderings).
      grid : array-like, shape=(n_points, len(target_variables))
          The grid of ``target_variables`` values for which the
          partial dependecy should be evaluated (either ``grid`` or ``X``
          must be specified).
      X : array-like, shape=(n_samples, n_features)
          The data on which ``gbrt`` was trained. It is used to generate
          a ``grid`` for the ``target_variables``. The ``grid`` comprises
          ``grid_resolution`` equally spaced points between the two
          ``percentiles``.
      percentiles : (low, high), default=(0.05, 0.95)
          The lower and upper percentile used create the extreme values
          for the ``grid``. Only if ``X`` is not None.
      grid_resolution : int, default=100
          The number of equally spaced points on the ``grid``.
  
      Returns
      -------
      pdp : array, shape=(n_classes, n_points)
          The partial dependence function evaluated on the ``grid``.
          For regression and binary classification ``n_classes==1``.
      axes : seq of ndarray or None
          The axes with which the grid has been created or None if
          the grid has been given.
  
      Examples
      --------
      >>> samples = [[0, 0, 2], [1, 0, 0]]
      >>> labels = [0, 1]
      >>> from sklearn.ensemble import GradientBoostingClassifier
      >>> gb = GradientBoostingClassifier(random_state=0).fit(samples, labels)
      >>> kwargs = dict(X=samples, percentiles=(0, 1), grid_resolution=2)
      >>> partial_dependence(gb, [0], **kwargs) # doctest: +SKIP
      (array([[-4.52...,  4.52...]]), [array([ 0.,  1.])])
      """
      if not isinstance(gbrt, BaseGradientBoosting):
          raise ValueError(
              "gbrt has to be an instance of BaseGradientBoosting"
          )
      if gbrt.estimators_.shape[0] == 0:
          raise ValueError(
              "Call %s.fit before partial_dependence"
              % gbrt.__class__.__name__
          )
      if (grid is None and X is None) or (
          grid is not None and X is not None
      ):
          raise ValueError("Either grid or X must be specified")
  
      target_variables = np.asarray(
          target_variables, dtype=np.int32, order="C"
      ).ravel()
  
      if any(
          [not (0 <= fx < gbrt.n_features) for fx in target_variables]
      ):
          raise ValueError(
              "target_variables must be in [0, %d]"
              % (gbrt.n_features - 1)
          )
  
      if X is not None:
          X = check_array(X, dtype=DTYPE, order="C")
          grid, axes = _grid_from_X(
              X[:, target_variables], percentiles, grid_resolution
          )
      else:
          assert grid is not None
          # dont return axes if grid is given
          axes = None
          # grid must be 2d
          if grid.ndim == 1:
              grid = grid[:, np.newaxis]
          if grid.ndim != 2:
              raise ValueError("grid must be 2d but is %dd" % grid.ndim)
  
      grid = np.asarray(grid, dtype=DTYPE, order="C")
      assert grid.shape[1] == target_variables.shape[0]
  
      n_trees_per_stage = gbrt.estimators_.shape[1]
      n_estimators = gbrt.estimators_.shape[0]
      pdp = np.zeros(
          (
              n_trees_per_stage,
              grid.shape[0],
          ),
          dtype=np.float64,
          order="C",
      )
      for stage in range(n_estimators):
          for k in range(n_trees_per_stage):
              tree = gbrt.estimators_[stage, k].tree_
              _partial_dependence_tree(
                  tree,
                  grid,
                  target_variables,
                  gbrt.learning_rate,
                  pdp[k],
              )
  
      return pdp, axes
  
file_path: catboost/contrib/python/scikit-learn/py2/sklearn/ensemble/partial_dependence.py
imports: from itertools import count
  import numbers
  import numpy
  from scipy.stats.mstats import mquantiles
  from ..utils.extmath import cartesian
  from ..externals.joblib import Parallel, delayed
  from ..externals import six
  from ..externals.six.moves import map, range, zip
  from ..utils import check_array
  from ..tree._tree import DTYPE
  from ._gradient_boosting import _partial_dependence_tree
  from .gradient_boosting import BaseGradientBoosting
label_desc: Use image node_id 2 for calling a global function with example usage: partial_dependence(gbrt, target_variables, grid, X, percentiles, grid_resolution) and returns: pdp,  axes