class_docstr: Visualizer for a sequence of AdditiveExplanation, as a stacked force plot.
class_docstr_tok: ["Visualizer","for","a","sequence","of","AdditiveExplanation",",","as","a","stacked","force","plot","."]
code: def __init__(
      self,
      arr,
      plot_cmap="RdBu",
      ordering_keys=None,
      ordering_keys_time_format=None,
  ):
      if not isinstance(arr[0], AdditiveExplanation):
          emsg = (
              "AdditiveForceArrayVisualizer can only visualize arrays of "
              "AdditiveExplanation objects!"
          )
          raise TypeError(emsg)
  
      # order the samples by their position in a hierarchical clustering
      if all(e.model.f == arr[1].model.f for e in arr):
          clustOrder = hclust_ordering(
              np.vstack([e.effects for e in arr])
          )
      else:
          emsg = "Tried to visualize an array of explanations from different models!"
          raise ValueError(emsg)
  
      # make sure that we put the higher predictions first...just for consistency
      if sum(arr[clustOrder[0]].effects) < sum(
          arr[clustOrder[-1]].effects
      ):
          np.flipud(clustOrder)  # reverse
  
      # build the json data
      clustOrder = np.argsort(clustOrder)  # inverse permutation
      self.data = {
          "outNames": arr[0].model.out_names,
          "baseValue": ensure_not_numpy(arr[0].base_value),
          "link": arr[0].link.__str__(),
          "featureNames": arr[0].data.group_names,
          "explanations": [],
          "plot_cmap": plot_cmap,
          "ordering_keys": list(ordering_keys)
          if hasattr(ordering_keys, "__iter__")
          else None,
          "ordering_keys_time_format": ordering_keys_time_format,
      }
      for ind, e in enumerate(arr):
          self.data["explanations"].append(
              {
                  "outValue": ensure_not_numpy(e.out_value),
                  "simIndex": ensure_not_numpy(clustOrder[ind]) + 1,
                  "features": {},
              }
          )
          for i in filter(
              lambda j: e.effects[j] != 0 or e.instance.x[0, j] != 0,
              range(len(e.data.group_names)),
          ):
              self.data["explanations"][-1]["features"][i] = {
                  "effect": ensure_not_numpy(e.effects[i]),
                  "value": ensure_not_numpy(
                      e.instance.group_display_values[i]
                  ),
              }
  
imports: import base64
  import json
  import os
  import random
  import re
  import string
  import warnings
  from collections.abc import Sequence
  import numpy
  import pandas
  import scipy.sparse
  from ..plots._force_matplotlib import draw_additive_plot
  from ..utils import hclust_ordering
  from ..utils._exceptions import DimensionError
  from ..utils._legacy import Data, DenseData, Instance, Link, Model, convert_to_link
  from ._labels import labels
label_desc: Use image node_id 1 to create a new AdditiveForceArrayVisualizer object from inherited base classes: BaseVisualizer with example: obj = AdditiveForceArrayVisualizer(arr, plot_cmap, ordering_keys, ordering_keys_time_format)