code: def _compute_tiling(
      model,
      X: np.ndarray,
      y: np.ndarray,
      binary_threshold,
      ntiles,
      tile_fraction,
      ranges,
  ):
      """
      Create grid over the range of x1 and x2 variables; use the model to
      compute the probabilities with model.predict_proba(), which will work with sklearn
      and, I think, XGBoost. Later we will have to figure out how to get probabilities
      out of the other models we support.
  
      The predictions are computed simply by picking the argmax of probabilities, which
      assumes classes are 0..k-1. TODO: update to allow disjoint integer class values
  
      For k=2 binary classifications, there is no way to set the threshold and so
      a threshold of 0.5 is implicitly chosen by argmax.
  
      This returns all of the details needed to plot the tiles. The coordinates of
      the grid are a linear space from min to max of each variable, inclusively.
      So if the range is 1..5 and we want 5 tiles, then the width of each tile is 1.
      We get a tile at each position. When we are drawing, the position is taken as
      the center of the tile. In this case, the grid points would be centered over
      1,2,3,4, and 5.
      """
      if isinstance(X, pd.DataFrame):
          X = X.values
      if isinstance(y, pd.Series):
          y = y.values
  
      X1 = X[:, 0]
      X2 = X[:, 1]
  
      if ranges is not None:
          x1range, x2range = ranges
          min_x1, max_x1 = x1range
          min_x2, max_x2 = x2range
      else:
          min_x1, max_x1 = min(X1), max(X1)
          min_x2, max_x2 = min(X2), max(X2)
  
      x1r = max_x1 - min_x1
      x2r = max_x2 - min_x2
      border1 = x1r * 0.05  # make a 5% border
      border2 = x2r * 0.05
      x1range = (min_x1 - border1, max_x1 + border1)
      x2range = (min_x2 - border2, max_x2 + border2)
      w = (x1r + 2 * border1) / (ntiles - 1)
      h = (x2r + 2 * border2) / (ntiles - 1)
      w *= tile_fraction
      h *= tile_fraction
  
      grid_points = []  # a list of coordinate pairs for the grid
      # Iterate through v1 (x-axis) most quickly then v2 (y-axis)
      for iv2, v2 in enumerate(
          np.linspace(*x2range, num=ntiles, endpoint=True)
      ):
          for iv1, v1 in enumerate(
              np.linspace(*x1range, num=ntiles, endpoint=True)
          ):
              grid_points.append([v1, v2])
      grid_points = np.array(grid_points)
  
      class_values = np.unique(y)
      class_X = [X[y == cl] for cl in class_values]
  
      grid_proba = _predict_proba(model, grid_points)
  
      if len(np.unique(y)) == 2:  # is k=2 binary?
          grid_pred = np.where(
              grid_proba[:, 1] >= binary_threshold, 1, 0
          )
      else:
          grid_pred = np.argmax(
              grid_proba, axis=1
          )  # TODO: assumes classes are 0..k-1
  
      return (
          grid_points,
          grid_proba,
          grid_pred,
          w,
          h,
          class_X,
          class_values,
      )
  
file_path: dtreeviz/dtreeviz/classifiers.py
imports: from typing import Tuple
  import matplotlib.pyplot
  import numpy
  import pandas
  from PIL import ImageColor
  from colour import Color
  from matplotlib import patches
  from matplotlib.collections import PatchCollection
  from dtreeviz import utils
  from dtreeviz.colors import adjust_colors
  from dtreeviz.utils import add_classifier_legend, _format_axes
label_desc: Use image node_id 3 for calling a global function with example usage: _compute_tiling(model, X, y, binary_threshold, ntiles, tile_fraction, ranges) and returns: grid_points,  grid_proba,  grid_pred,  w,  h,  class_X,  class_values