class_docstr: Base functionality for some train-test performance checks.
code: def _prepare_display(
      self,
      results: pd.DataFrame,
      train_dataset_name: str,
      test_dataset_name: str,
      classes_without_enough_samples: t.Optional[t.List[str]] = None,
      top_classes_to_show: t.Optional[t.List[str]] = None,
  ):
      display_df = results.replace(
          {
              "Dataset": {
                  DEFAULT_DATASET_NAMES[0]: train_dataset_name,
                  DEFAULT_DATASET_NAMES[1]: test_dataset_name,
              }
          }
      )
  
      figures = []
      data_scorers_per_class = display_df[results["Class"].notna()]
      data_scorers_per_dataset = display_df[
          results["Class"].isna()
      ].drop(columns=["Class"])
  
      # Filter classes without enough samples and get display comment for them:
      if classes_without_enough_samples:
          data_scorers_per_class = data_scorers_per_class.loc[
              ~data_scorers_per_class["Class"].isin(
                  classes_without_enough_samples
              )
          ]
  
      # Filter top classes to show:
      if top_classes_to_show:
          not_shown_classes = list(
              set(data_scorers_per_class["Class"].unique())
              - set(top_classes_to_show)
          )
          data_scorers_per_class = data_scorers_per_class.loc[
              data_scorers_per_class["Class"].isin(top_classes_to_show)
          ]
      else:
          not_shown_classes = None
  
      for data in (data_scorers_per_dataset, data_scorers_per_class):
          if data.shape[0] == 0:
              continue
  
          fig = px.histogram(
              data,
              x="Class" if "Class" in data.columns else "Dataset",
              y="Value",
              color="Dataset",
              barmode="group",
              facet_col="Metric",
              facet_col_spacing=0.05,
              hover_data=["Number of samples"],
              color_discrete_map={
                  train_dataset_name: colors[DEFAULT_DATASET_NAMES[0]],
                  test_dataset_name: colors[DEFAULT_DATASET_NAMES[1]],
              },
          )
  
          figures.append(
              fig.update_xaxes(
                  title=None,
                  type="category",
                  tickangle=60,
              )
              .update_yaxes(title=None, matches=None)
              .for_each_annotation(
                  lambda a: a.update(text=a.text.split("=")[-1])
              )
              .for_each_yaxis(
                  lambda yaxis: yaxis.update(showticklabels=True)
              )
              .add_annotation(
                  text="Class",
                  showarrow=False,
                  xref="paper",
                  yref="paper",
                  y=-0.1,
                  x=-0.1,
              )
          )
  
      # Add comments about not shown classes:
      df = pd.DataFrame({}, columns=["Reason", "Classes"]).set_index(
          "Reason"
      )
      if not_shown_classes:
          df.loc[
              f"Not shown classes (showing only top {len(top_classes_to_show)})"
          ] = str(not_shown_classes)
      if classes_without_enough_samples:
          df.loc[
              f"Classes without enough samples in either {train_dataset_name} or {test_dataset_name}"
          ] = str(classes_without_enough_samples)
  
      if not df.empty:
          figures.append(df)
  
      return figures
  
file_path: deepchecks/deepchecks/utils/abstracts/train_test_performace.py
imports: import abc
  import typing
  import pandas
  import plotly.express
  from typing_extensions import Self
  from deepchecks.core.check_utils.class_performance_utils import get_condition_class_performance_imbalance_ratio_less_than, get_condition_test_performance_greater_than, get_condition_train_test_relative_degradation_less_than
  from deepchecks.utils.plot import DEFAULT_DATASET_NAMES, colors
  from deepchecks.utils.strings import format_percent
label_desc: Use image node_id 1 for calling the TrainTestPerformanceAbstract obj's underlying member method code with example usage: obj._prepare_display(results, train_dataset_name, test_dataset_name, classes_without_enough_samples, top_classes_to_show) and returns: figures