docstr: Accumulated Local Effects for tabular datasets. Current implementation supports first order
  feature effects of numerical features.
  
  Parameters
  ----------
  predictor
      A callable that takes in an `N x F` array as input and outputs an `N x T` array (`N` - number of
      data points, `F` - number of features, `T` - number of outputs/targets (e.g. 1 for single output
      regression, >=2 for classification)).
  feature_names
      A list of feature names used for displaying results.
  target_names
      A list of target/output names used for displaying results.
  check_feature_resolution
      If ``True``, the number of unique values is calculated for each feature and if it is less than
      `low_resolution_threshold` then the feature values are used for grid-points instead of quantiles.
      This may increase the runtime of the algorithm for large datasets. Only used for features without custom
      grid-points specified in :py:meth:`alibi.explainers.ale.ALE.explain`.
  low_resolution_threshold
      If a feature has at most this many unique values, these are used as the grid points instead of
      quantiles. This is to avoid situations when the quantile algorithm returns quantiles between discrete
      values which can result in jumps in the ALE plot obscuring the true effect. Only used if
      `check_feature_resolution` is ``True`` and for features without custom grid-points specified in
      :py:meth:`alibi.explainers.ale.ALE.explain`.
  extrapolate_constant
      If a feature is constant, only one quantile exists where all the data points lie. In this case the
      ALE value at that point is zero, however this may be misleading if the feature does have an effect on
      the model. If this parameter is set to ``True``, the ALE values are calculated on an interval surrounding
      the constant value. The interval length is controlled by the `extrapolate_constant_perc` and
      `extrapolate_constant_min` arguments.
  extrapolate_constant_perc
      Percentage by which to extrapolate a constant feature value to create an interval for ALE calculation.
      If `q` is the constant feature value, creates an interval
      `[q - q/extrapolate_constant_perc, q + q/extrapolate_constant_perc]` for which ALE is calculated.
      Only relevant if `extrapolate_constant` is set to ``True``.
  extrapolate_constant_min
      Controls the minimum extrapolation length for constant features. An interval constructed for constant
      features is guaranteed to be `2 x extrapolate_constant_min` wide centered on the feature value. This allows
      for capturing model behaviour around constant features which have small value so that
      `extrapolate_constant_perc` is not so helpful.
      Only relevant if `extrapolate_constant` is set to ``True``.
docstr_tok: ["Accumulated","Local","Effects","for","tabular","datasets",".","Current","implementation","supports","first","order","feature","effects","of","numerical","features",".","Parameters","--","--","--","--","--","predictor","A","callable","that","takes","in","an","`","N","x","F","`","array","as","input","and","outputs","an","`","N","x","T","`","array","(","`","N","`","-","number","of","data","points",",","`","F","`","-","number","of","features",",","`","T","`","-","number","of","outputs\/targets","(","e.g",".","1","for","single","output","regression",",",">","=2","for","classification",")",")",".","feature_names","A","list","of","feature","names","used","for","displaying","results",".","target_names","A","list","of","target\/output","names","used","for","displaying","results",".","check_feature_resolution","If","``","True","``",",","the","number","of","unique","values","is","calculated","for","each","feature","and","if","it","is","less","than","`","low_resolution_threshold","`","then","the","feature","values","are","used","for","grid-points","instead","of","quantiles",".","This","may","increase","the","runtime","of","the","algorithm","for","large","datasets",".","Only","used","for","features","without","custom","grid-points","specified","in",":","py",":","meth",":","`","alibi.explainers.ale.ALE.explain","`",".","low_resolution_threshold","If","a","feature","has","at","most","this","many","unique","values",",","these","are","used","as","the","grid","points","instead","of","quantiles",".","This","is","to","avoid","situations","when","the","quantile","algorithm","returns","quantiles","between","discrete","values","which","can","result","in","jumps","in","the","ALE","plot","obscuring","the","true","effect",".","Only","used","if","`","check_feature_resolution","`","is","``","True","``","and","for","features","without","custom","grid-points","specified","in",":","py",":","meth",":","`","alibi.explainers.ale.ALE.explain","`",".","extrapolate_constant","If","a","feature","is","constant",",","only","one","quantile","exists","where","all","the","data","points","lie",".","In","this","case","the","ALE","value","at","that","point","is","zero",",","however","this","may","be","misleading","if","the","feature","does","have","an","effect","on","the","model",".","If","this","parameter","is","set","to","``","True","``",",","the","ALE","values","are","calculated","on","an","interval","surrounding","the","constant","value",".","The","interval","length","is","controlled","by","the","`","extrapolate_constant_perc","`","and","`","extrapolate_constant_min","`","arguments",".","extrapolate_constant_perc","Percentage","by","which","to","extrapolate","a","constant","feature","value","to","create","an","interval","for","ALE","calculation",".","If","`","q","`","is","the","constant","feature","value",",","creates","an","interval","`","[","q","-","q\/extrapolate_constant_perc",",","q","+","q\/extrapolate_constant_perc","]","`","for","which","ALE","is","calculated",".","Only","relevant","if","`","extrapolate_constant","`","is","set","to","``","True","``",".","extrapolate_constant_min","Controls","the","minimum","extrapolation","length","for","constant","features",".","An","interval","constructed","for","constant","features","is","guaranteed","to","be","`","2","x","extrapolate_constant_min","`","wide","centered","on","the","feature","value",".","This","allows","for","capturing","model","behaviour","around","constant","features","which","have","small","value","so","that","`","extrapolate_constant_perc","`","is","not","so","helpful",".","Only","relevant","if","`","extrapolate_constant","`","is","set","to","``","True","``","."]
code: def __init__(
      self,
      predictor: Callable[[np.ndarray], np.ndarray],
      feature_names: Optional[List[str]] = None,
      target_names: Optional[List[str]] = None,
      check_feature_resolution: bool = True,
      low_resolution_threshold: int = 10,
      extrapolate_constant: bool = True,
      extrapolate_constant_perc: float = 10.0,
      extrapolate_constant_min: float = 0.1,
  ) -> None:
      """
      Accumulated Local Effects for tabular datasets. Current implementation supports first order
      feature effects of numerical features.
  
      Parameters
      ----------
      predictor
          A callable that takes in an `N x F` array as input and outputs an `N x T` array (`N` - number of
          data points, `F` - number of features, `T` - number of outputs/targets (e.g. 1 for single output
          regression, >=2 for classification)).
      feature_names
          A list of feature names used for displaying results.
      target_names
          A list of target/output names used for displaying results.
      check_feature_resolution
          If ``True``, the number of unique values is calculated for each feature and if it is less than
          `low_resolution_threshold` then the feature values are used for grid-points instead of quantiles.
          This may increase the runtime of the algorithm for large datasets. Only used for features without custom
          grid-points specified in :py:meth:`alibi.explainers.ale.ALE.explain`.
      low_resolution_threshold
          If a feature has at most this many unique values, these are used as the grid points instead of
          quantiles. This is to avoid situations when the quantile algorithm returns quantiles between discrete
          values which can result in jumps in the ALE plot obscuring the true effect. Only used if
          `check_feature_resolution` is ``True`` and for features without custom grid-points specified in
          :py:meth:`alibi.explainers.ale.ALE.explain`.
      extrapolate_constant
          If a feature is constant, only one quantile exists where all the data points lie. In this case the
          ALE value at that point is zero, however this may be misleading if the feature does have an effect on
          the model. If this parameter is set to ``True``, the ALE values are calculated on an interval surrounding
          the constant value. The interval length is controlled by the `extrapolate_constant_perc` and
          `extrapolate_constant_min` arguments.
      extrapolate_constant_perc
          Percentage by which to extrapolate a constant feature value to create an interval for ALE calculation.
          If `q` is the constant feature value, creates an interval
          `[q - q/extrapolate_constant_perc, q + q/extrapolate_constant_perc]` for which ALE is calculated.
          Only relevant if `extrapolate_constant` is set to ``True``.
      extrapolate_constant_min
          Controls the minimum extrapolation length for constant features. An interval constructed for constant
          features is guaranteed to be `2 x extrapolate_constant_min` wide centered on the feature value. This allows
          for capturing model behaviour around constant features which have small value so that
          `extrapolate_constant_perc` is not so helpful.
          Only relevant if `extrapolate_constant` is set to ``True``.
      """
      super().__init__(meta=copy.deepcopy(DEFAULT_META_ALE))
  
      self.predictor = predictor
      self.feature_names = feature_names
      self.target_names = target_names
      self.check_feature_resolution = check_feature_resolution
      self.low_resolution_threshold = low_resolution_threshold
      self.extrapolate_constant = extrapolate_constant
      self.extrapolate_constant_perc = extrapolate_constant_perc
      self.extrapolate_constant_min = extrapolate_constant_min
  
      self.meta["params"].update(
          check_feature_resolution=check_feature_resolution,
          low_resolution_threshold=low_resolution_threshold,
          extrapolate_constant=extrapolate_constant,
          extrapolate_constant_perc=extrapolate_constant_perc,
          extrapolate_constant_min=extrapolate_constant_min,
      )
  
imports: import copy
  import math
  import numpy
  import pandas
  from itertools import count
  from functools import partial
  from typing import Callable, List, Optional, Tuple, Union, Dict, TYPE_CHECKING, no_type_check
  import sys
  import logging
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.api.defaults import DEFAULT_META_ALE, DEFAULT_DATA_ALE
label_desc: Use image node_id 1 to create a new ALE object from inherited base classes: Explainer with example: obj = ALE(predictor, feature_names, target_names, check_feature_resolution, low_resolution_threshold, extrapolate_constant, extrapolate_constant_perc, extrapolate_constant_min)