class_docstr: RandomStratified Splitter class.
  
  For sparse multitask datasets, a standard split offers no guarantees that the
  splits will have any activate compounds. This class guarantees that each task
  will have a proportional split of the activates in a split. TO do this, a
  ragged split is performed with different numbers of compounds taken from each
  task. Thus, the length of the split arrays may exceed the split of the
  original array. That said, no datapoint is copied to more than one split, so
  correctness is still ensured.
  
  Note that this splitter is only valid for boolean label data.
  
  TODO(rbharath): This splitter should be refactored to match style of other
  splitter classes.
class_docstr_tok: ["RandomStratified","Splitter","class",".","For","sparse","multitask","datasets",",","a","standard","split","offers","no","guarantees","that","the","splits","will","have","any","activate","compounds",".","This","class","guarantees","that","each","task","will","have","a","proportional","split","of","the","activates","in","a","split",".","TO","do","this",",","a","ragged","split","is","performed","with","different","numbers","of","compounds","taken","from","each","task",".","Thus",",","the","length","of","the","split","arrays","may","exceed","the","split","of","the","original","array",".","That","said",",","no","datapoint","is","copied","to","more","than","one","split",",","so","correctness","is","still","ensured",".","Note","that","this","splitter","is","only","valid","for","boolean","label","data",".","TODO","(","rbharath",")",":","This","splitter","should","be","refactored","to","match","style","of","other","splitter","classes","."]
docstr: Custom split due to raggedness in original split.
      
docstr_tok: ["Custom","split","due","to","raggedness","in","original","split","."]
code: def train_valid_test_split(
      self,
      dataset,
      train_dir=None,
      valid_dir=None,
      test_dir=None,
      frac_train=0.8,
      frac_valid=0.1,
      frac_test=0.1,
      seed=None,
      log_every_n=1000,
  ):
      """Custom split due to raggedness in original split."""
      if train_dir is None:
          train_dir = tempfile.mkdtemp()
      if valid_dir is None:
          valid_dir = tempfile.mkdtemp()
      if test_dir is None:
          test_dir = tempfile.mkdtemp()
      # Obtain original x, y, and w arrays and shuffle
      X, y, w, ids = randomize_arrays(
          (dataset.X, dataset.y, dataset.w, dataset.ids)
      )
      rem_dir = tempfile.mkdtemp()
      train_dataset, rem_dataset = self.split(
          dataset, frac_train, [train_dir, rem_dir]
      )
  
      # calculate percent split for valid (out of test and valid)
      if frac_valid + frac_test > 0:
          valid_percentage = frac_valid / (frac_valid + frac_test)
      else:
          return train_dataset, None, None
      # split test data into valid and test, treating sub test set also as sparse
      valid_dataset, test_dataset = self.split(
          dataset, valid_percentage, [valid_dir, test_dir]
      )
  
      return train_dataset, valid_dataset, test_dataset
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import tempfile
  import numpy
  import itertools
  from rdkit import Chem
  from rdkit import DataStructs
  from rdkit.Chem import AllChem
  from rdkit.ML.Cluster import Butina
  import deepchem
  from deepchem.data import DiskDataset
  from deepchem.utils import ScaffoldGenerator
  from deepchem.utils.save import log
  from deepchem.data import NumpyDataset
  from deepchem.utils.save import load_data
label_desc: Use image node_id 4 for calling the RandomStratifiedSplitter obj's underlying member method code with example usage: obj.train_valid_test_split(dataset, train_dir, valid_dir, test_dir, frac_train, frac_valid, frac_test, seed, log_every_n) and returns: train_dataset,  valid_dataset,  test_dataset, train_dataset,  None,  None