class_docstr: Test some basic splitters.
docstr: Test RandomStratifiedSplitter k-fold class.
code: def test_singletask_stratified_k_fold_split(self):
      """
      Test RandomStratifiedSplitter k-fold class.
      """
      n_samples = 100
      n_positives = 20
      n_features = 10
  
      X = np.random.rand(n_samples, n_features)
      y = np.zeros(n_samples)
      y[:n_positives] = 1
      w = np.ones(n_samples)
      ids = np.arange(n_samples)
  
      dataset = dc.data.DiskDataset.from_numpy(X, y, w, ids)
  
      stratified_splitter = dc.splits.RandomStratifiedSplitter()
      ids_set = set(dataset.ids)
  
      K = 5
      fold_datasets = stratified_splitter.k_fold_split(dataset, K)
      fold_datasets = [f[1] for f in fold_datasets]
  
      for fold in range(K):
          fold_dataset = fold_datasets[fold]
          # Verify lengths is 100/k == 20
          # Note: This wouldn't work for multitask str
          # assert len(fold_dataset) == n_samples/K
          fold_labels = fold_dataset.y
          # Verify that each fold has n_positives/K = 4 positive examples.
          assert np.count_nonzero(fold_labels == 1) == n_positives / K
          # Verify that compounds in this fold are subset of original compounds
          fold_ids_set = set(fold_dataset.ids)
          assert fold_ids_set.issubset(ids_set)
          # Verify that no two folds have overlapping compounds.
          for other_fold in range(K):
              if fold == other_fold:
                  continue
              other_fold_dataset = fold_datasets[other_fold]
              other_fold_ids_set = set(other_fold_dataset.ids)
              assert fold_ids_set.isdisjoint(other_fold_ids_set)
  
      merged_dataset = dc.data.DiskDataset.merge(fold_datasets)
      assert len(merged_dataset) == len(dataset)
      assert sorted(merged_dataset.ids) == (sorted(dataset.ids))
  
imports: import os
  import unittest
  import numpy
  import deepchem
  from deepchem.data import NumpyDataset
  from deepchem.splits import IndexSplitter
label_desc: Use image node_id 19 for calling the TestSplitter obj's underlying member method code with example usage: obj.test_singletask_stratified_k_fold_split() without return types