class_docstr: Abstract base class for chemically aware splits..
class_docstr_tok: ["Abstract","base","class","for","chemically","aware","splits",".."]
docstr: Does K-fold split of dataset.
docstr_tok: ["Does","K-fold","split","of","dataset","."]
code: def k_fold_split(self, dataset, k, directories=None):
      """Does K-fold split of dataset."""
      log("Computing K-fold split", self.verbose)
      if directories is None:
          directories = [tempfile.mkdtemp() for _ in range(k)]
      else:
          assert len(directories) == k
      fold_datasets = []
      # rem_dataset is remaining portion of dataset
      rem_dataset = dataset
      for fold in range(k):
          # Note starts as 1/k since fold starts at 0. Ends at 1 since fold goes up
          # to k-1.
          frac_fold = 1.0 / (k - fold)
          fold_dir = directories[fold]
          fold_inds, rem_inds, _ = self.split(
              rem_dataset,
              frac_train=frac_fold,
              frac_valid=1 - frac_fold,
              frac_test=0,
          )
          fold_dataset = rem_dataset.select(fold_inds, fold_dir)
          rem_dir = tempfile.mkdtemp()
          rem_dataset = rem_dataset.select(rem_inds, rem_dir)
          fold_datasets.append(fold_dataset)
      return fold_datasets
  
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 2 for calling the Splitter obj's underlying member method code with example usage: obj.k_fold_split(dataset, k, directories) and returns: fold_datasets