class_docstr: Test that the random split utility in the text analytics toolkit works
  properly.
class_docstr_tok: ["Test","that","the","random","split","utility","in","the","text","analytics","toolkit","works","properly","."]
docstr: Test that the random split utility in the text analytics toolkit works
  properly.
docstr_tok: ["Test","that","the","random","split","utility","in","the","text","analytics","toolkit","works","properly","."]
code: def test_random_split(self):
      """
      Test that the random split utility in the text analytics toolkit works
      properly.
      """
  
      train, test = text_analytics.random_split(self.docs)
  
      assert len(train) == len(self.docs)
      assert len(test) == len(self.docs)
  
      # Iterate through each doc and each word
      for i in range(len(self.docs)):
          a = train[i]
          b = test[i]
  
          # Make sure there are no zero values
          for k, v in a.items():
              assert v != 0
          for k, v in b.items():
              assert v != 0
  
          # Make sure the counts add up to the original counts
          for k, v in self.docs[i].items():
              av = 0
              bv = 0
              if k in a:
                  av = a[k]
              if k in b:
                  bv = b[k]
              assert v == av + bv
  
      # Check that a low probability puts fewer items in the test set
      train, test = text_analytics.random_split(self.docs, prob=0.001)
  
      total_in_train = train.dict_values().apply(lambda x: sum(x)).sum()
      total_in_test = test.dict_values().apply(lambda x: sum(x)).sum()
      assert total_in_train > total_in_test
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import math
  import unittest
  import warnings
  import turicreate
  import turicreate.toolkits.text_analytics
  from .None import util
label_desc: Use image node_id 2 for calling the RandomWordSplitTest obj's underlying member method code with example usage: obj.test_random_split() without return types