docstr: Select a random index subject to constraints component
  
  Args:
      explainer (Explainer): explainer object constructed with either
                  ClassifierExplainer() or RegressionExplainer()
      title (str, optional): Title of tab or page. Defaults to
                  "Select Random Index".
      name (str, optional): unique name to add to Component elements.
                  If None then random uuid is generated to make sure
                  it's unique. Defaults to None.
      subtitle (str): subtitle
      hide_title (bool, optional): hide title
      hide_subtitle (bool, optional): Hide subtitle. Defaults to False.
      hide_index (bool, optional): Hide index selector.
                  Defaults to False.
      hide_pred_slider (bool, optional): Hide prediction slider.
                  Defaults to False.
      hide_residual_slider (bool, optional): hide residuals slider.
                  Defaults to False.
      hide_pred_or_y (bool, optional): hide prediction or actual toggle.
                  Defaults to False.
      hide_abs_residuals (bool, optional): hide absolute residuals toggle.
                  Defaults to False.
      hide_button (bool, optional): hide button. Defaults to False.
      index_dropdown (bool, optional): Use dropdown for index input instead
          of free text input. Defaults to True.
      index ({str, int}, optional): Initial index to display.
                  Defaults to None.
      pred_slider ([lb, ub], optional): Initial values for prediction
                  values slider [lowerbound, upperbound]. Defaults to None.
      y_slider ([lb, ub], optional): Initial values for y slider
                  [lower bound, upper bound]. Defaults to None.
      residual_slider ([lb, ub], optional): Initial values for residual slider
                  [lower bound, upper bound]. Defaults to None.
      abs_residual_slider ([lb, ub], optional): Initial values for absolute
                  residuals slider [lower bound, upper bound]
                  Defaults to None.
      pred_or_y (str, {'preds', 'y'}, optional): Initial use predictions
                  or y slider. Defaults to "preds".
      abs_residuals (bool, optional): Initial use residuals or absolute
                  residuals. Defaults to True.
      round (int, optional): rounding used for slider spacing. Defaults to 2.
      description (str, optional): Tooltip to display when hover over
          component title. When None default text is shown.
code: def __init__(
      self,
      explainer,
      title=None,
      name=None,
      subtitle="Select from list or pick at random",
      hide_title=False,
      hide_subtitle=False,
      hide_index=False,
      hide_pred_slider=False,
      hide_residual_slider=False,
      hide_pred_or_y=False,
      hide_abs_residuals=False,
      hide_button=False,
      index_dropdown=True,
      index=None,
      pred_slider=None,
      y_slider=None,
      residual_slider=None,
      abs_residual_slider=None,
      pred_or_y="preds",
      abs_residuals=True,
      round=2,
      description=None,
      **kwargs,
  ):
      """Select a random index subject to constraints component
  
      Args:
          explainer (Explainer): explainer object constructed with either
                      ClassifierExplainer() or RegressionExplainer()
          title (str, optional): Title of tab or page. Defaults to
                      "Select Random Index".
          name (str, optional): unique name to add to Component elements.
                      If None then random uuid is generated to make sure
                      it's unique. Defaults to None.
          subtitle (str): subtitle
          hide_title (bool, optional): hide title
          hide_subtitle (bool, optional): Hide subtitle. Defaults to False.
          hide_index (bool, optional): Hide index selector.
                      Defaults to False.
          hide_pred_slider (bool, optional): Hide prediction slider.
                      Defaults to False.
          hide_residual_slider (bool, optional): hide residuals slider.
                      Defaults to False.
          hide_pred_or_y (bool, optional): hide prediction or actual toggle.
                      Defaults to False.
          hide_abs_residuals (bool, optional): hide absolute residuals toggle.
                      Defaults to False.
          hide_button (bool, optional): hide button. Defaults to False.
          index_dropdown (bool, optional): Use dropdown for index input instead
              of free text input. Defaults to True.
          index ({str, int}, optional): Initial index to display.
                      Defaults to None.
          pred_slider ([lb, ub], optional): Initial values for prediction
                      values slider [lowerbound, upperbound]. Defaults to None.
          y_slider ([lb, ub], optional): Initial values for y slider
                      [lower bound, upper bound]. Defaults to None.
          residual_slider ([lb, ub], optional): Initial values for residual slider
                      [lower bound, upper bound]. Defaults to None.
          abs_residual_slider ([lb, ub], optional): Initial values for absolute
                      residuals slider [lower bound, upper bound]
                      Defaults to None.
          pred_or_y (str, {'preds', 'y'}, optional): Initial use predictions
                      or y slider. Defaults to "preds".
          abs_residuals (bool, optional): Initial use residuals or absolute
                      residuals. Defaults to True.
          round (int, optional): rounding used for slider spacing. Defaults to 2.
          description (str, optional): Tooltip to display when hover over
              component title. When None default text is shown.
      """
      super().__init__(
          explainer, title or f"Select {explainer.index_name}", name
      )
      assert self.explainer.is_regression, (
          "explainer is not a RegressionExplainer so the RegressionRandomIndexComponent "
          "will not work. Try using the ClassifierRandomIndexComponent instead."
      )
  
      # if self.title is None:
      #     self.title = f"Select {self.explainer.index_name}"
  
      self.index_name = "random-index-reg-index-" + self.name
      self.index_selector = IndexSelector(
          explainer,
          self.index_name,
          index=index,
          index_dropdown=index_dropdown,
          **kwargs,
      )
  
      if self.explainer.y_missing:
          self.hide_residual_slider = True
          self.hide_pred_or_y = True
          self.hide_abs_residuals = True
          self.pred_or_y = "preds"
          self.y_slider = [0.0, 1.0]
          self.residual_slider = [0.0, 1.0]
          self.abs_residual_slider = [0.0, 1.0]
  
      if self.pred_slider is None:
          self.pred_slider = [
              float(self.explainer.preds.min()),
              float(self.explainer.preds.max()),
          ]
  
      if not self.explainer.y_missing:
          if self.y_slider is None:
              self.y_slider = [
                  float(self.explainer.y.min()),
                  float(self.explainer.y.max()),
              ]
  
          if self.residual_slider is None:
              self.residual_slider = [
                  float(self.explainer.residuals.min()),
                  float(self.explainer.residuals.max()),
              ]
  
          if self.abs_residual_slider is None:
              self.abs_residual_slider = [
                  float(self.explainer.abs_residuals.min()),
                  float(self.explainer.abs_residuals.max()),
              ]
  
          assert (
              len(self.pred_slider) == 2
              and self.pred_slider[0] <= self.pred_slider[1]
          ), "pred_slider should be a list of a [lower_bound, upper_bound]!"
  
          assert (
              len(self.y_slider) == 2
              and self.y_slider[0] <= self.y_slider[1]
          ), "y_slider should be a list of a [lower_bound, upper_bound]!"
  
          assert (
              len(self.residual_slider) == 2
              and self.residual_slider[0] <= self.residual_slider[1]
          ), "residual_slider should be a list of a [lower_bound, upper_bound]!"
  
          assert (
              len(self.abs_residual_slider) == 2
              and self.abs_residual_slider[0]
              <= self.abs_residual_slider[1]
          ), "abs_residual_slider should be a list of a [lower_bound, upper_bound]!"
  
      self.y_slider = [float(y) for y in self.y_slider]
      self.pred_slider = [float(p) for p in self.pred_slider]
      self.residual_slider = [float(r) for r in self.residual_slider]
      self.abs_residual_slider = [
          float(a) for a in self.abs_residual_slider
      ]
  
      assert self.pred_or_y in {
          "preds",
          "y",
      }, "pred_or_y should be in ['preds', 'y']!"
  
      if self.description is None:
          self.description = f"""
          You can select a {self.explainer.index_name} directly by choosing it 
          from the dropdown (if you start typing you can search inside the list),
          or hit the Random {self.explainer.index_name} button to randomly select
          a {self.explainer.index_name} that fits the constraints. For example
          you can select a {self.explainer.index_name} with a very high predicted
          {self.explainer.target}, or a very low observed {self.explainer.target},
          or a {self.explainer.index_name} whose predicted {self.explainer.target} 
          was very far off from the observed {self.explainer.target} and so had a 
          high (absolute) residual.
          """
  
imports: import numpy
  import pandas
  import dash
  from dash import html, dcc, Input, Output, State
  from dash.exceptions import PreventUpdate
  import dash_bootstrap_components
  from ..dashboard_methods import *
  from ..None import to_html
label_desc: Use image node_id 1 to create a new RegressionRandomIndexComponent object from inherited base classes: ExplainerComponent with example: obj = RegressionRandomIndexComponent(explainer, title, name, subtitle, hide_title, hide_subtitle, hide_index, hide_pred_slider, hide_residual_slider, hide_pred_or_y, hide_abs_residuals, hide_button, index_dropdown, index, pred_slider, y_slider, residual_slider, abs_residual_slider, pred_or_y, abs_residuals, round, description)