class_docstr: Find new labels in test.
  
  Parameters
  ----------
  n_samples : int , default: 10_000_000
      number of samples to use for this check.
  random_state : int, default: 42
      random seed for all check internals.
class_docstr_tok: ["Find","new","labels","in","test",".","Parameters","--","--","--","--","--","n_samples",":","int",",","default",":","10_000_000","number","of","samples","to","use","for","this","check",".","random_state",":","int",",","default",":","42","random","seed","for","all","check","internals","."]
docstr: Run check.
  
  Returns
  -------
  CheckResult
      value is a dictionary that shows label column with new labels
      displays a dataframe that label columns with new labels
  
  Raises
  ------
  DeepchecksValueError
      If the datasets are not a Dataset instance or do not contain label column
docstr_tok: ["Run","check",".","Returns","--","--","--","-","CheckResult","value","is","a","dictionary","that","shows","label","column","with","new","labels","displays","a","dataframe","that","label","columns","with","new","labels","Raises","--","--","--","DeepchecksValueError","If","the","datasets","are","not","a","Dataset","instance","or","do","not","contain","label","column"]
code: def run_logic(self, context: Context) -> CheckResult:
      """Run check.
  
      Returns
      -------
      CheckResult
          value is a dictionary that shows label column with new labels
          displays a dataframe that label columns with new labels
  
      Raises
      ------
      DeepchecksValueError
          If the datasets are not a Dataset instance or do not contain label column
      """
      test_dataset = context.test.sample(
          self.n_samples, random_state=self.random_state
      )
      train_dataset = context.train.sample(
          self.n_samples, random_state=self.random_state
      )
      context.assert_classification_task()
  
      n_test_samples = test_dataset.n_samples
  
      train_label = train_dataset.label_col
      test_label = test_dataset.label_col
  
      unique_training_values = set(train_label.unique())
      unique_test_values = set(test_label.unique())
  
      new_labels = unique_test_values.difference(unique_training_values)
  
      if new_labels:
          new_labels = test_label[test_label.isin(new_labels)]
          n_new_label = len(new_labels)
          samples_per_label = dict(new_labels.value_counts())
  
          result = {
              "n_samples": n_test_samples,
              "n_new_labels_samples": n_new_label,
              "new_labels": sorted(samples_per_label.keys()),
              "n_samples_per_new_label": samples_per_label,
          }
  
          if context.with_display:
              dataframe = pd.DataFrame(
                  data=[
                      [
                          train_dataset.label_name,
                          format_percent(n_new_label / n_test_samples),
                          sorted(new_labels),
                      ]
                  ],
                  columns=[
                      "Label column",
                      "Percent new labels in sample",
                      "New labels",
                  ],
              )
              dataframe = dataframe.set_index(["Label column"])
              display = dataframe
          else:
              display = None
  
      else:
          display = None
          result = {
              "n_samples": n_test_samples,
              "n_new_labels_samples": 0,
              "new_labels": [],
              "n_samples_per_new_label": {},
          }
  
      return CheckResult(result, display=display)
  
file_path: deepchecks/deepchecks/tabular/checks/train_test_validation/new_label_train_test.py
imports: from typing import Dict
  import pandas
  from deepchecks.core import CheckResult, ConditionCategory, ConditionResult
  from deepchecks.core.reduce_classes import ReduceLabelMixin
  from deepchecks.tabular import Context, TrainTestCheck
  from deepchecks.utils.strings import format_percent
label_desc: Use image node_id 2 for calling the NewLabelTrainTest obj's underlying member method code with example usage: obj.run_logic(context) and returns: CheckResult