class_docstr: Tree-based model `sklearn`  implementation of the partial dependence for tabular datasets.
  Supports multiple feature interactions. This method is faster than the general black-box implementation
  but is only supported by some tree-based estimators. The computation is based on a weighted tree traversal.
  For more details on the computation, check the `sklearn documentation page`_. The supported `sklearn`
  models are: `GradientBoostingClassifier`, `GradientBoostingRegressor`, `HistGradientBoostingClassifier`,
  `HistGradientBoostingRegressor`, `HistGradientBoostingRegressor`, `DecisionTreeRegressor`, `RandomForestRegressor`.
  
  .. _sklearn documentation page:
          https://scikit-learn.org/stable/modules/partial_dependence.html#computation-methods
class_docstr_tok: ["Tree-based","model","`","sklearn","`","implementation","of","the","partial","dependence","for","tabular","datasets",".","Supports","multiple","feature","interactions",".","This","method","is","faster","than","the","general","black-box","implementation","but","is","only","supported","by","some","tree-based","estimators",".","The","computation","is","based","on","a","weighted","tree","traversal",".","For","more","details","on","the","computation",",","check","the","`","sklearn","documentation","page","`","_",".","The","supported","`","sklearn","`","models","are",":","`","GradientBoostingClassifier","`",",","`","GradientBoostingRegressor","`",",","`","HistGradientBoostingClassifier","`",",","`","HistGradientBoostingRegressor","`",",","`","HistGradientBoostingRegressor","`",",","`","DecisionTreeRegressor","`",",","`","RandomForestRegressor","`",".","..","_sklearn","documentation","page",":","https",":","\/\/scikit-learn.org\/stable\/modules\/partial_dependence.html","#","computation-methods"]
docstr: Calculates the partial dependence for each feature and/or tuples of features with respect to the all targets
  and the reference dataset `X`.
  
  Parameters
  ----------
  X
      A `N x F` tabular dataset used to calculate partial dependence curves. This is typically the
      training dataset or a representative sample.
  features
      An optional list of features or tuples of features for which to calculate the partial dependence.
      If not provided, the partial dependence will be computed for every single features in the dataset.
      Some example for `features` would be: ``[0, 2]``, ``[0, 2, (0, 2)]``, ``[(0, 2)]``, where
      ``0`` and ``2`` correspond to column 0 and 2 in `X`, respectively.
  percentiles
      Lower and upper percentiles used to limit the feature values to potentially remove outliers from
      low-density regions. Note that for features with not many data points with large/low values, the
      PD estimates are less reliable in those extreme regions. The values must be in [0, 1]. Only used
      with `grid_resolution`.
  grid_resolution
      Number of equidistant points to split the range of each target feature. Only applies if the number of
      unique values of a target feature in the reference dataset `X` is greater than the `grid_resolution` value.
      For example, consider a case where a feature can take the following values:
      ``[0.1, 0.3, 0.35, 0.351, 0.4, 0.41, 0.44, ..., 0.5, 0.54, 0.56, 0.6, 0.65, 0.7, 0.9]``, and we are not
      interested in evaluating the marginal effect at every single point as it can become computationally costly
      (assume hundreds/thousands of points) without providing any additional information for nearby points
      (e.g., 0.35 and 351). By setting ``grid_resolution=5``, the marginal effect is computed for the values
      ``[0.1, 0.3, 0.5, 0.7, 0.9]`` instead, which is less computationally demanding and can provide similar
      insights regarding the model's behaviour. Note that the extreme values of the grid can be controlled
      using the `percentiles` argument.
  grid_points
      Custom grid points. Must be a `dict` where the keys are the target features indices and the values are
      monotonically increasing arrays defining the grid points for a numerical feature, and a subset of
      categorical feature values for a categorical feature. If the `grid_points` are not specified,
      then the grid will be constructed based on the unique target feature values available in the
      dataset `X`, or based on the `grid_resolution` and `percentiles` (check `grid_resolution` to see when
      it applies). For categorical features, the corresponding value in the `grid_points` can be
      specified either as array of strings or array of integers corresponding the label encodings.
      Note that the label encoding must match the ordering of the values provided in the `categorical_names`.
docstr_tok: ["Calculates","the","partial","dependence","for","each","feature","and\/or","tuples","of","features","with","respect","to","the","all","targets","and","the","reference","dataset","`","X","`",".","Parameters","--","--","--","--","--","X","A","`","N","x","F","`","tabular","dataset","used","to","calculate","partial","dependence","curves",".","This","is","typically","the","training","dataset","or","a","representative","sample",".","features","An","optional","list","of","features","or","tuples","of","features","for","which","to","calculate","the","partial","dependence",".","If","not","provided",",","the","partial","dependence","will","be","computed","for","every","single","features","in","the","dataset",".","Some","example","for","`","features","`","would","be",":","``","[","0",",","2","]","``",",","``","[","0",",","2",",","(","0",",","2",")","]","``",",","``","[","(","0",",","2",")","]","``",",","where","``","0","``","and","``","2","``","correspond","to","column","0","and","2","in","`","X","`",",","respectively",".","percentiles","Lower","and","upper","percentiles","used","to","limit","the","feature","values","to","potentially","remove","outliers","from","low-density","regions",".","Note","that","for","features","with","not","many","data","points","with","large\/low","values",",","the","PD","estimates","are","less","reliable","in","those","extreme","regions",".","The","values","must","be","in","[","0",",","1","]",".","Only","used","with","`","grid_resolution","`",".","grid_resolution","Number","of","equidistant","points","to","split","the","range","of","each","target","feature",".","Only","applies","if","the","number","of","unique","values","of","a","target","feature","in","the","reference","dataset","`","X","`","is","greater","than","the","`","grid_resolution","`","value",".","For","example",",","consider","a","case","where","a","feature","can","take","the","following","values",":","``","[","0.1",",","0.3",",","0.35",",","0.351",",","0.4",",","0.41",",","0.44",",","...",",","0.5",",","0.54",",","0.56",",","0.6",",","0.65",",","0.7",",","0.9","]","``",",","and","we","are","not","interested","in","evaluating","the","marginal","effect","at","every","single","point","as","it","can","become","computationally","costly","(","assume","hundreds\/thousands","of","points",")","without","providing","any","additional","information","for","nearby","points","(","e.g.",",","0.35","and","351",")",".","By","setting","``","grid_resolution=5","``",",","the","marginal","effect","is","computed","for","the","values","``","[","0.1",",","0.3",",","0.5",",","0.7",",","0.9","]","``","instead",",","which","is","less","computationally","demanding","and","can","provide","similar","insights","regarding","the","model","'s","behaviour",".","Note","that","the","extreme","values","of","the","grid","can","be","controlled","using","the","`","percentiles","`","argument",".","grid_points","Custom","grid","points",".","Must","be","a","`","dict","`","where","the","keys","are","the","target","features","indices","and","the","values","are","monotonically","increasing","arrays","defining","the","grid","points","for","a","numerical","feature",",","and","a","subset","of","categorical","feature","values","for","a","categorical","feature",".","If","the","`","grid_points","`","are","not","specified",",","then","the","grid","will","be","constructed","based","on","the","unique","target","feature","values","available","in","the","dataset","`","X","`",",","or","based","on","the","`","grid_resolution","`","and","`","percentiles","`","(","check","`","grid_resolution","`","to","see","when","it","applies",")",".","For","categorical","features",",","the","corresponding","value","in","the","`","grid_points","`","can","be","specified","either","as","array","of","strings","or","array","of","integers","corresponding","the","label","encodings",".","Note","that","the","label","encoding","must","match","the","ordering","of","the","values","provided","in","the","`","categorical_names","`","."]
code: def explain(
      self,  # type: ignore[override]
      X: np.ndarray,
      features: Optional[List[Union[int, Tuple[int, int]]]] = None,
      percentiles: Tuple[float, float] = (0.0, 1.0),
      grid_resolution: int = 100,
      grid_points: Optional[Dict[int, Union[List, np.ndarray]]] = None,
  ) -> Explanation:
      """
      Calculates the partial dependence for each feature and/or tuples of features with respect to the all targets
      and the reference dataset `X`.
  
      Parameters
      ----------
      X
          A `N x F` tabular dataset used to calculate partial dependence curves. This is typically the
          training dataset or a representative sample.
      features
          An optional list of features or tuples of features for which to calculate the partial dependence.
          If not provided, the partial dependence will be computed for every single features in the dataset.
          Some example for `features` would be: ``[0, 2]``, ``[0, 2, (0, 2)]``, ``[(0, 2)]``, where
          ``0`` and ``2`` correspond to column 0 and 2 in `X`, respectively.
      percentiles
          Lower and upper percentiles used to limit the feature values to potentially remove outliers from
          low-density regions. Note that for features with not many data points with large/low values, the
          PD estimates are less reliable in those extreme regions. The values must be in [0, 1]. Only used
          with `grid_resolution`.
      grid_resolution
          Number of equidistant points to split the range of each target feature. Only applies if the number of
          unique values of a target feature in the reference dataset `X` is greater than the `grid_resolution` value.
          For example, consider a case where a feature can take the following values:
          ``[0.1, 0.3, 0.35, 0.351, 0.4, 0.41, 0.44, ..., 0.5, 0.54, 0.56, 0.6, 0.65, 0.7, 0.9]``, and we are not
          interested in evaluating the marginal effect at every single point as it can become computationally costly
          (assume hundreds/thousands of points) without providing any additional information for nearby points
          (e.g., 0.35 and 351). By setting ``grid_resolution=5``, the marginal effect is computed for the values
          ``[0.1, 0.3, 0.5, 0.7, 0.9]`` instead, which is less computationally demanding and can provide similar
          insights regarding the model's behaviour. Note that the extreme values of the grid can be controlled
          using the `percentiles` argument.
      grid_points
          Custom grid points. Must be a `dict` where the keys are the target features indices and the values are
          monotonically increasing arrays defining the grid points for a numerical feature, and a subset of
          categorical feature values for a categorical feature. If the `grid_points` are not specified,
          then the grid will be constructed based on the unique target feature values available in the
          dataset `X`, or based on the `grid_resolution` and `percentiles` (check `grid_resolution` to see when
          it applies). For categorical features, the corresponding value in the `grid_points` can be
          specified either as array of strings or array of integers corresponding the label encodings.
          Note that the label encoding must match the ordering of the values provided in the `categorical_names`.
      """
      return super().explain(
          X=X,
          features=features,
          kind=Kind.AVERAGE.value,  # only `'average'` is supported for `'recursion'` method.
          percentiles=percentiles,
          grid_resolution=grid_resolution,
          grid_points=grid_points,
      )
  
imports: import copy
  import logging
  import math
  import numbers
  import sys
  from abc import ABC, abstractmethod
  from enum import Enum
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union, no_type_check
  import matplotlib.pyplot
  import numpy
  from scipy.stats.mstats import mquantiles
  from sklearn.base import BaseEstimator, is_classifier, is_regressor
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.ensemble._gb import BaseGradientBoosting
  from sklearn.ensemble._hist_gradient_boosting.gradient_boosting import BaseHistGradientBoosting
  from sklearn.tree import DecisionTreeRegressor
  from sklearn.utils.extmath import cartesian
  from sklearn.utils.validation import check_is_fitted
  from tqdm import tqdm
  from alibi.api.defaults import DEFAULT_DATA_PD, DEFAULT_META_PD
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.explainers.ale import get_quantiles
  from alibi.utils import _get_options_string
label_desc: Use image node_id 3 for calling the TreePartialDependence obj's underlying member method code with example usage: obj.explain(X, features, percentiles, grid_resolution, grid_points) and returns: super