class_docstr: Bridge pattern decoupling the application part from SmartExplainer and SmartPlotter.
  Attributes
  ----------
  explainer: object
      SmartExplainer instance to point to.
class_docstr_tok: ["Bridge","pattern","decoupling","the","application","part","from","SmartExplainer","and","SmartPlotter",".","Attributes","--","--","--","--","--","explainer",":","object","SmartExplainer","instance","to","point","to","."]
docstr: Initialize components (graph, table, filter, settings, ...) and insert it inside
  components containers which are created by init_skeleton
docstr_tok: ["Initialize","components","(","graph",",","table",",","filter",",","settings",",","...",")","and","insert","it","inside","components","containers","which","are","created","by","init_skeleton"]
code: def init_components(self):
      """
      Initialize components (graph, table, filter, settings, ...) and insert it inside
      components containers which are created by init_skeleton
      """
  
      self.components["settings"]["input_rows"] = create_input_modal(
          id="rows",
          label="Number of rows for subset",
          tooltip="Set max number of lines for subset (datatable). \
                       Filter will be apply on this subset.",
      )
  
      self.components["settings"]["input_points"] = create_input_modal(
          id="points",
          label="Number of points for plot",
          tooltip="Set max number of points in feature contribution plots.",
      )
  
      self.components["settings"][
          "input_features"
      ] = create_input_modal(
          id="features",
          label="Number of features to plot",
          tooltip="Set max number of features to plot in features \
                       importance and local explanation plots.",
      )
  
      self.components["settings"]["input_violin"] = create_input_modal(
          id="violin",
          label="Max number of labels for violin plot",
          tooltip="Set max number of labels to display a violin plot \
                       for feature contribution plot (otherwise a scatter \
                                                      plot is displayed).",
      )
  
      self.components["settings"]["name"] = dbc.Row(
          [
              dbc.Checklist(
                  options=[
                      {
                          "label": "Use domain name for \
                                features name.",
                          "value": 1,
                      }
                  ],
                  value=[],
                  inline=True,
                  id="name",
                  style={"margin-left": "20px"},
              ),
              dbc.Tooltip(
                  "Replace technical feature names by \
                              domain names if exists.",
                  target="name",
                  placement="bottom",
              ),
          ],
          className="g-3",
      )
  
      self.components["settings"]["modal"] = dbc.Modal(
          [
              dbc.ModalHeader("Settings"),
              dbc.ModalBody(
                  dbc.Form(
                      [
                          self.components["settings"]["input_rows"],
                          self.components["settings"]["input_points"],
                          self.components["settings"]["input_features"],
                          self.components["settings"]["input_violin"],
                          self.components["settings"]["name"],
                      ]
                  )
              ),
              dbc.ModalFooter(
                  dbc.Button("Apply", id="apply", className="ml-auto")
              ),
          ],
          id="modal",
      )
  
      self.components["menu"] = dbc.Row(
          [
              dbc.Col(
                  [
                      html.Div(
                          daq.BooleanSwitch(
                              id="bool_groups",
                              on=True,
                              style={"display": "none"}
                              if self.explainer.features_groups is None
                              else {},
                              color=self.color[0],
                              label={
                                  "label": "Groups",
                                  "style": {
                                      "fontSize": 18,
                                      "color": self.color[0],
                                      "fontWeight": "bold",
                                      "margin-left": "5px",
                                  },
                              },
                              labelPosition="right",
                          ),
                          style={"margin-right": "35px"},
                      )
                  ],
                  width="auto",
                  align="center",
              ),
              dbc.Col(
                  [
                      html.H4(
                          [
                              dbc.Badge(
                                  "Regression",
                                  id="regression_badge",
                                  style={
                                      "margin-right": "5px",
                                      "margin-left": "0px",
                                  },
                                  color="",
                              ),
                              dbc.Badge(
                                  "Classification",
                                  id="classification_badge",
                                  color="",
                              ),
                          ],
                          style={"margin-right": "5px"},
                      ),
                  ],
                  width="auto",
                  align="center",
                  style={"padding": "auto"},
              ),
              dbc.Col(
                  dbc.Collapse(
                      dbc.Row(
                          [
                              # 2 columns to have class beside the dropdown buttons
                              dbc.Col(
                                  [
                                      dbc.Label(
                                          "Class:",
                                          style={
                                              "color": "white",
                                              "margin": "0px",
                                          },
                                      ),
                                  ],
                                  align="center",
                              ),
                              dbc.Col(
                                  [
                                      dcc.Dropdown(
                                          id="select_label",
                                          options=[],
                                          value=None,
                                          clearable=False,
                                          searchable=False,
                                          style={
                                              "verticalAlign": "middle",
                                              "zIndex": "1010",
                                              "min-width": "160px",
                                              "height": "100%",
                                          },
                                      )
                                  ],
                                  style={
                                      "margin-right": "17px",
                                      "padding": "0px",
                                      "width": "auto",
                                  },
                              ),
                          ],
                          style={"margin": "0px"},
                      ),
                      is_open=True,
                      id="select_collapse",
                  ),
                  width="auto",
                  align="center",
                  style={"padding": "0px"},
              ),
              dbc.Col(
                  [
                      html.Div(
                          [
                              html.Img(
                                  id="settings",
                                  title="settings",
                                  alt="Settings",
                                  src=self.app.get_asset_url(
                                      "settings.png"
                                  ),
                                  height="40px",
                                  style={"cursor": "pointer"},
                              ),
                              self.components["settings"]["modal"],
                          ]
                      )
                  ],
                  align="center",
                  width="auto",
                  style={"padding": "0px"},
              ),
          ],
          className="g-0",
          justify="end",
      )
  
      self.adjust_menu()
  
      self.components["table"]["dataset"] = dash_table.DataTable(
          id="dataset",
          data=self.round_dataframe.to_dict("records"),
          tooltip_data=[
              {
                  column: {"value": str(value), "type": "text"}
                  for column, value in row.items()
              }
              for row in self.dataframe.to_dict("index").values()
          ],
          tooltip_duration=2000,
          columns=[
              {"name": i, "id": i} for i in self.dataframe.columns
          ],
          tooltip_header={
              column: self.features_dict[column]
              for column in self.dataframe.columns
              if column not in self.special_cols
          },
          editable=False,
          row_deletable=False,
          virtualization=True,
          page_action="none",
          fixed_rows={"headers": True, "data": 0},
          fixed_columns={"headers": True, "data": 0},
          sort_action="custom",
          sort_mode="multi",
          sort_by=[],
          style_table={"overflowY": "auto", "overflowX": "auto"},
          style_header={"height": "30px"},
          style_cell={
              "minWidth": "70px",
              "width": "120px",
              "maxWidth": "200px",
              "textOverflow": "ellipsis",
          },
      )
  
      self.components["graph"]["global_feature_importance"] = MyGraph(
          figure=go.Figure(), id="global_feature_importance"
      )
  
      self.components["graph"]["feature_selector"] = MyGraph(
          figure=go.Figure(), id="feature_selector"
      )
  
      # Component for the graph prediction picking
      self.components["graph"]["prediction_picking"] = MyGraph(
          figure=go.Figure(), id="prediction_picking"
      )
  
      self.components["graph"]["detail_feature"] = MyGraph(
          figure=go.Figure(), id="detail_feature"
      )
  
      # Component create to filter the dataset
      self.components["filter"]["filter_dataset"] = dbc.Col(
          [
              dbc.Row(
                  html.Div(
                      id="main",
                      children=[
                          html.Div(
                              id="filters",
                              children=[
                                  # Create Add Filter button
                                  dbc.Button(
                                      id="add_dropdown_button",
                                      children="Add Filter",
                                      color="warning",
                                      size="sm",
                                      style={"margin-right": "20px"},
                                  ),
                                  # Create reset Filter button (disabled of no filters applied)
                                  dbc.Button(
                                      id="reset_dropdown_button",
                                      children="Reset all existing filters",
                                      color="warning",
                                      disabled=True,
                                      size="sm",
                                      style={"margin-right": "20px"},
                                  ),
                                  # Create explanation button
                                  dbc.Button(
                                      "?",
                                      id="open_filter",
                                      size="sm",
                                      color="warning",
                                  ),
                                  # Create popover on the explanation button
                                  dbc.Popover(
                                      "Click here to know how you can apply filters.",
                                      target="open_filter",
                                      body=True,
                                      trigger="hover",
                                  ),
                                  # Modal associated to the explanation button
                                  dbc.Modal(
                                      [
                                          dbc.ModalHeader(
                                              dbc.ModalTitle(
                                                  "Filters explanation"
                                              )
                                          ),
                                          dbc.ModalBody(
                                              [
                                                  html.Div(
                                                      dcc.Markdown(
                                                          self.explanations.filter
                                                      )
                                                  )
                                              ]
                                          ),
                                          dbc.ModalFooter(
                                              dbc.Button(
                                                  "Close",
                                                  id="close_filter",
                                                  color="warning",
                                              )
                                          ),
                                      ],
                                      id="modal_filter",
                                      centered=True,
                                      size="lg",
                                  ),
                                  # Div which will contains the filters
                                  html.Div(
                                      id="dropdowns_container",
                                      children=[],
                                  ),
                              ],
                          )
                      ],
                  )
              ),
              dbc.Row(
                  html.Div(
                      [
                          html.Br(),
                          # Create Apply Filter button (Hidden if no filter to apply)
                          dbc.Button(
                              id="apply_filter",
                              children="Apply filters",
                              color="warning",
                              size="sm",
                              style={"display": "none"},
                          ),
                          dbc.Label(
                              id="filtered_subset_info",
                              children="Test",
                              width="auto",
                              style={"display": "none"},
                          ),
                      ],
                  )
              ),
          ],
          style={
              "maxheight": "22rem",
              "height": "21rem",
              "zIndex": 800,
          },
      )
  
      self.components["filter"]["index"] = dbc.Col(
          dbc.Row(
              [
                  dbc.Col(
                      [
                          dbc.Input(
                              id="index_id",
                              type=get_index_type(self.dataframe),
                              size="s",
                              placeholder="_index_",
                              debounce=True,
                              persistence=True,
                              style={"textAlign": "right"},
                          )
                      ],
                      width={"size": 5},
                      style={"padding": "0px"},
                  ),
                  dbc.Col(
                      [
                          html.Img(
                              id="validation",
                              alt="Validate",
                              title="Validate index",
                              src=self.app.get_asset_url("reload.png"),
                              height="30px",
                              style={"cursor": "pointer"},
                          )
                      ],
                      width={"size": 1},
                      style={"padding": "0px"},
                      align="center",
                  ),
                  dbc.Col(
                      [
                          dbc.Button(
                              "ID Card",
                              id="id_card",
                              color="warning",
                              style={"display": "none"},
                          ),
                          dbc.Popover(
                              "Click here to visualize the identity card of the selected sample.",
                              target="id_card",
                              body=True,
                              trigger="hover",
                          ),
                          dbc.Modal(
                              [
                                  dbc.ModalHeader(
                                      dbc.Col(
                                          [
                                              dbc.ModalTitle(
                                                  "Identity Card"
                                              ),
                                              dbc.Row(
                                                  [
                                                      dbc.Label(
                                                          "Sort by:",
                                                          align="center",
                                                          width="auto",
                                                      ),
                                                      dbc.Col(
                                                          [
                                                              dcc.Dropdown(
                                                                  id="select_id_card_sorting",
                                                                  options=[
                                                                      {
                                                                          "label": "Label",
                                                                          "value": "feature_name",
                                                                      },
                                                                      {
                                                                          "label": "Contribution",
                                                                          "value": "feature_contrib",
                                                                      },
                                                                  ],
                                                                  value="feature_name",
                                                                  clearable=False,
                                                                  searchable=False,
                                                              ),
                                                          ],
                                                          width=3,
                                                      ),
                                                      dbc.Label(
                                                          "Order:",
                                                          align="center",
                                                          width="auto",
                                                      ),
                                                      dbc.Col(
                                                          [
                                                              dcc.Dropdown(
                                                                  id="select_id_card_order",
                                                                  options=[
                                                                      {
                                                                          "label": "Ascending",
                                                                          "value": True,
                                                                      },
                                                                      {
                                                                          "label": "Descending",
                                                                          "value": False,
                                                                      },
                                                                  ],
                                                                  value=True,
                                                                  clearable=False,
                                                                  searchable=False,
                                                              ),
                                                          ],
                                                          width=3,
                                                      ),
                                                  ],
                                                  style={
                                                      "margin-top": "0.5rem"
                                                  },
                                              ),
                                              dbc.Row(
                                                  [
                                                      dbc.Label(
                                                          "Label",
                                                          width=3,
                                                          style={
                                                              "fontWeight": "bold"
                                                          },
                                                      ),
                                                      dbc.Label(
                                                          "Value",
                                                          width=5,
                                                          style={
                                                              "fontWeight": "bold"
                                                          },
                                                      ),
                                                      dbc.Col(width=1),
                                                      dbc.Label(
                                                          "Contribution",
                                                          id="id_card_title_contrib",
                                                          width=3,
                                                          style={
                                                              "fontWeight": "bold"
                                                          },
                                                      ),
                                                  ],
                                                  style={
                                                      "margin-top": "0.5rem",
                                                      "margin-bottom": "-1rem",
                                                  },
                                              ),
                                          ]
                                      ),
                                      close_button=False,
                                  ),
                                  dbc.ModalBody(id="id_card_body"),
                                  dbc.ModalFooter(
                                      dbc.Button(
                                          "Close",
                                          id="close_id_card",
                                          color="warning",
                                      )
                                  ),
                              ],
                              id="modal_id_card",
                              centered=True,
                              size="xl",
                              scrollable=True,
                          ),
                      ],
                      width=5,
                  ),
              ],
              justify="center",
          )
      )
  
      self.components["filter"]["threshold"] = dbc.Col(
          [
              dbc.Label(
                  "Threshold", html_for="slider", id="threshold_label"
              ),
              dcc.Slider(
                  min=0,
                  max=self.max_threshold,
                  value=0,
                  step=0.1,
                  marks={
                      f"{round(self.max_threshold * mark / 4)}": f"{round(self.max_threshold * mark / 4)}"
                      for mark in range(5)
                  },
                  id="threshold_id",
              ),
          ],
          className="filter_dashed",
      )
  
      self.components["filter"]["max_contrib"] = dbc.Col(
          [
              dbc.Label(
                  "Features to display: ", id="max_contrib_label"
              ),
              dcc.Slider(
                  min=1,
                  max=min(
                      self.settings["features"],
                      len(self.explainer.x_init.columns),
                  ),
                  step=1,
                  value=min(
                      self.settings["features"],
                      len(self.explainer.x_init.columns),
                  ),
                  id="max_contrib_id",
              ),
          ],
          className="filter_dashed",
      )
  
      self.components["filter"]["positive_contrib"] = dbc.Col(
          [
              dbc.Row(
                  [
                      dbc.Label(
                          "Contributions to display:",
                          style={"font-size": "95%"},
                      ),
                  ]
              ),
              dbc.Row(
                  [
                      dbc.Col(
                          dbc.Checklist(
                              options=[
                                  {"label": "Positive", "value": 1}
                              ],
                              value=[1],
                              inline=True,
                              id="check_id_positive",
                              # define the font-size style
                              style={"font-size": "82%"},
                          ),
                          style={"display": "inline-block"},
                      ),
                      dbc.Col(
                          dbc.Checklist(
                              options=[
                                  {"label": "Negative", "value": 1}
                              ],
                              value=[1],
                              inline=True,
                              id="check_id_negative",
                              # define the font-size style
                              style={"font-size": "82%"},
                          ),
                          style={"display": "inline-block"},
                          align="center",
                      ),
                  ],
                  className="g-0",
                  justify="center",
              ),
          ],
          className="filter_dashed",
      )
  
      self.components["filter"]["masked_contrib"] = dbc.Col(
          [
              dbc.Label("Feature(s) to mask:"),
              dcc.Dropdown(
                  options=[
                      {"label": key, "value": value}
                      for key, value in sorted(
                          self.explainer.inv_features_dict.items(),
                          key=lambda item: item[0],
                      )
                  ],
                  value="",
                  multi=True,
                  searchable=True,
                  id="masked_contrib_id",
              ),
          ],
          className="filter_dashed",
      )
  
imports: import copy
  import dash
  from dash import dash_table
  import dash_daq
  from dash import no_update
  from dash.exceptions import PreventUpdate
  import dash_bootstrap_components
  from dash import dcc
  from dash import html
  from dash import MATCH, ALL
  from dash.dependencies import Output, Input, State
  from flask import Flask
  import pandas
  import plotly.graph_objs
  import random
  import re
  from math import log10
  from shapash.webapp.utils.utils import check_row, get_index_type, round_to_k
  from shapash.webapp.utils.MyGraph import MyGraph
  from shapash.utils.utils import truncate_str
  from shapash.webapp.utils.explanations import Explanations
  from shapash.webapp.utils.callbacks import select_data_from_prediction_picking, select_data_from_str_filters, select_data_from_bool_filters, select_data_from_numeric_filters, select_data_from_date_filters, get_feature_from_clicked_data, get_feature_from_features_groups, get_group_name, get_indexes_from_datatable, update_click_data_on_subset_changes, get_figure_zoom, get_feature_contributions_sign_to_show, update_features_to_display, get_id_card_features, get_id_card_contrib, create_id_card_data, create_id_card_layout, get_feature_filter_options, create_dropdown_feature_filter, create_filter_modalities_selection
label_desc: Use image node_id 3 for calling the SmartApp obj's underlying member method code with example usage: obj.init_components() without return types