class_docstr: Explanation object specific to trees.
class_docstr_tok: ["Explanation","object","specific","to","trees","."]
docstr: Provides interactive visualizations.
  
  Args:
      key: Either a scalar or list
          that indexes the internal object for sub-plotting.
          If an overall visualization is requested, pass None.
  
  Returns:
      A Dash Cytoscape object.
docstr_tok: ["Provides","interactive","visualizations",".","Args",":","key",":","Either","a","scalar","or","list","that","indexes","the","internal","object","for","sub-plotting",".","If","an","overall","visualization","is","requested",",","pass","None",".","Returns",":","A","Dash","Cytoscape","object","."]
code: def visualize(self, key=None):
      """Provides interactive visualizations.
  
      Args:
          key: Either a scalar or list
              that indexes the internal object for sub-plotting.
              If an overall visualization is requested, pass None.
  
      Returns:
          A Dash Cytoscape object.
      """
      import dash_cytoscape as cyto
  
      data_dict = self.data(key)
      if data_dict is None:
          return None
  
      stylesheet = [
          {
              "selector": "edge",
              "style": {
                  "label": "data(label)",
                  "line-color": COLORS[0],
                  "width": "data(edge_weight)",
                  "line-style": "dotted",
              },
          },
          {
              "selector": "node",
              "style": {
                  "label": "data(label)",
                  "text-wrap": "wrap",
                  "background-color": COLORS[3],
                  "font-size": 20,
                  "font-weight": 500,
              },
          },
          {
              "selector": "[weight > 1]",
              "style": {
                  "line-color": COLORS[1],
                  "background-color": COLORS[4],
              },
          },
      ]
  
      # Handle overall graphs
      if key is None:
          component = cyto.Cytoscape(
              layout={"name": "breadthfirst", "roots": '[id = "1"]'},
              style={"width": "100%", "height": "390px"},
              # userZoomingEnabled=False,
              elements=data_dict["nodes"] + data_dict["edges"],
              stylesheet=stylesheet,
          )
          return component
  
      # Handle local instance graphs
      if self.explanation_type == "local":
          edges = data_dict["edges"]
          nodes = data_dict["nodes"]
          new_edges = self._weight_edges(edges, data_dict["decision"])
          new_nodes = self._weight_nodes_decision(
              nodes, data_dict["decision"]
          )
          component = cyto.Cytoscape(
              layout={"name": "breadthfirst", "roots": '[id = "1"]'},
              style={"width": "100%", "height": "390px"},
              elements=new_nodes + new_edges,
              stylesheet=stylesheet,
          )
          return component
      # Handle global feature graphs
      elif self.explanation_type == "global":
          feature = self.feature_names[key]
          nodes = data_dict["nodes"]
  
          feature_present = np.any(
              [feature == node["data"]["feature"] for node in nodes]
          )
          if not feature_present:
              figure = r"""
                          <style>
                          .center {{
                              position: absolute;
                              left: 50%;
                              top: 50%;
                              -webkit-transform: translate(-50%, -50%);
                              transform: translate(-50%, -50%);
                          }}
                          </style>
                          <div class='center'><h1>"{0}" is not used by this tree.</h1></div>
                      """
              figure = figure.format(feature)
              return figure
  
          new_nodes = self._weight_nodes_feature(nodes, feature)
          elements = new_nodes + data_dict["edges"]
          component = cyto.Cytoscape(
              layout={"name": "breadthfirst", "roots": '[id = "1"]'},
              style={"width": "100%", "height": "390px"},
              elements=elements,
              stylesheet=stylesheet,
          )
          return component
      else:  # pragma: no cover
          msg = "Cannot handle type {0}".format(self.explanation_type)
          _log.error(msg)
          raise Exception(msg)
  
imports: from ..api.base import ExplainerMixin, ExplanationMixin
  from ..utils._explanation import gen_name_from_class, gen_local_selector, gen_global_selector, gen_perf_dicts
  from sklearn.base import ClassifierMixin, RegressorMixin
  from sklearn.tree import DecisionTreeClassifier
  from sklearn.tree import DecisionTreeRegressor
  from sklearn.base import is_classifier
  from sklearn.utils.validation import check_is_fitted
  import numpy
  from abc import abstractmethod
  from sklearn.tree import _tree
  from copy import deepcopy
  from ..utils._clean_x import preclean_X
  from ..utils._clean_simple import clean_dimensions, typify_classification
  from ..utils._unify_data import unify_data
  import logging
label_desc: Use image node_id 3 for calling the TreeExplanation obj's underlying member method code with example usage: obj.visualize(key) and returns: None, component, component, component, figure