class_docstr: Data object used for all RasaModels.
  
  It contains all features needed to train the models.
  'data' is a mapping of attribute name, e.g. TEXT, INTENT, etc., and feature name,
  e.g. SENTENCE, SEQUENCE, etc., to a list of feature arrays representing the actual
  features.
  'label_key' and 'label_sub_key' point to the labels inside 'data'. For
  example, if your intent labels are stored under INTENT -> IDS, 'label_key' would
  be "INTENT" and 'label_sub_key' would be "IDS".
class_docstr_tok: ["Data","object","used","for","all","RasaModels",".","It","contains","all","features","needed","to","train","the","models",".","'data","'","is","a","mapping","of","attribute","name",",","e.g",".","TEXT",",","INTENT",",","etc.",",","and","feature","name",",","e.g",".","SENTENCE",",","SEQUENCE",",","etc.",",","to","a","list","of","feature","arrays","representing","the","actual","features",".","'label_key","'","and","'label_sub_key","'","point","to","the","labels","inside","'data","'",".","For","example",",","if","your","intent","labels","are","stored","under","INTENT","-",">","IDS",",","'label_key","'","would","be","``","INTENT","''","and","'label_sub_key","'","would","be","``","IDS","''","."]
docstr: Create random hold out test set using stratified split.
  
  Args:
      number_of_test_examples: Number of test examples.
      random_seed: Random seed.
  
  Returns:
      A tuple of train and test RasaModelData.
docstr_tok: ["Create","random","hold","out","test","set","using","stratified","split",".","Args",":","number_of_test_examples",":","Number","of","test","examples",".","random_seed",":","Random","seed",".","Returns",":","A","tuple","of","train","and","test","RasaModelData","."]
code: def split(
      self, number_of_test_examples: int, random_seed: int
  ) -> Tuple["RasaModelData", "RasaModelData"]:
      """Create random hold out test set using stratified split.
  
      Args:
          number_of_test_examples: Number of test examples.
          random_seed: Random seed.
  
      Returns:
          A tuple of train and test RasaModelData.
      """
      self._check_label_key()
  
      if self.label_key is None or self.label_sub_key is None:
          # randomly split data as no label key is set
          multi_values = [
              v
              for attribute_data in self.data.values()
              for data in attribute_data.values()
              for v in data
          ]
          solo_values: List[Any] = [
              []
              for attribute_data in self.data.values()
              for data in attribute_data.values()
              for _ in data
          ]
          stratify = None
      else:
          # make sure that examples for each label value are in both split sets
          label_ids = self._create_label_ids(
              self.data[self.label_key][self.label_sub_key][0]
          )
          label_counts: Dict[int, int] = dict(
              zip(
                  *np.unique(
                      label_ids,
                      return_counts=True,
                      axis=0,
                  )
              )
          )
  
          self._check_train_test_sizes(
              number_of_test_examples, label_counts
          )
  
          counts = np.array(
              [label_counts[label] for label in label_ids]
          )
          # we perform stratified train test split,
          # which insures every label is present in the train and test data
          # this operation can be performed only for labels
          # that contain several data points
          multi_values = [
              f[counts > 1].view(FeatureArray)
              for attribute_data in self.data.values()
              for features in attribute_data.values()
              for f in features
          ]
          # collect data points that are unique for their label
          solo_values = [
              f[counts == 1]
              for attribute_data in self.data.values()
              for features in attribute_data.values()
              for f in features
          ]
  
          stratify = label_ids[counts > 1]
  
      output_values = train_test_split(
          *multi_values,
          test_size=number_of_test_examples,
          random_state=random_seed,
          stratify=stratify,
      )
  
      return self._convert_train_test_split(output_values, solo_values)
  
imports: import logging
  from typing import Optional, DefaultDict, Dict, Iterable, Text, List, Tuple, Any, Union, NamedTuple, ItemsView, overload, cast
  from collections import defaultdict, OrderedDict
  import numpy
  import scipy.sparse
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 21 for calling the RasaModelData obj's underlying member method code with example usage: obj.split(number_of_test_examples, random_seed) and returns: self