class_docstr: Chemical diversity splitter.
  
  Class for doing splits based on the MaxMin diversity algorithm. Intuitively,
  the test set is comprised of the most diverse compounds of the entire dataset.
  Furthermore, the validation set is comprised of diverse compounds under
  the test set.
  
  Note
  ----
  This class requires RDKit to be installed.
  
  Examples
  --------
  >>> import deepchem as dc
  >>> import numpy as np
  >>> # creation of demo data set with some smiles strings
  >>> smiles= ['C', 'CC', 'CCC', 'CCCC', 'CCCCC']
  >>> Xs = np.zeros(len(smiles))
  >>> # creation of a deepchem dataset with the smile codes in the ids field
  >>> dataset = dc.data.DiskDataset.from_numpy(X=Xs,ids=smiles)
  >>> maxminsplitter = dc.splits.MaxMinSplitter()
  >>> train_dataset, test_dataset = maxminsplitter.train_test_split(dataset)
class_docstr_tok: ["Chemical","diversity","splitter",".","Class","for","doing","splits","based","on","the","MaxMin","diversity","algorithm",".","Intuitively",",","the","test","set","is","comprised","of","the","most","diverse","compounds","of","the","entire","dataset",".","Furthermore",",","the","validation","set","is","comprised","of","diverse","compounds","under","the","test","set",".","Note","--","--","This","class","requires","RDKit","to","be","installed",".","Examples","--","--","--","--",">",">",">","import","deepchem","as","dc",">",">",">","import","numpy","as","np",">",">",">","#","creation","of","demo","data","set","with","some","smiles","strings",">",">",">","smiles=","[","'","C","'",",","'CC","'",",","'CCC","'",",","'CCCC","'",",","'CCCCC","'","]",">",">",">","Xs","=","np.zeros","(","len","(","smiles",")",")",">",">",">","#","creation","of","a","deepchem","dataset","with","the","smile","codes","in","the","ids","field",">",">",">","dataset","=","dc.data.DiskDataset.from_numpy","(","X=Xs",",","ids=smiles",")",">",">",">","maxminsplitter","=","dc.splits.MaxMinSplitter","(",")",">",">",">","train_dataset",",","test_dataset","=","maxminsplitter.train_test_split","(","dataset",")"]
docstr: Splits internal compounds into train/validation/test using the MaxMin diversity algorithm.
  
  Parameters
  ----------
  dataset: Dataset
      Dataset to be split.
  frac_train: float, optional (default 0.8)
      The fraction of data to be used for the training split.
  frac_valid: float, optional (default 0.1)
      The fraction of data to be used for the validation split.
  frac_test: float, optional (default 0.1)
      The fraction of data to be used for the test split.
  seed: int, optional (default None)
      Random seed to use.
  log_every_n: int, optional (default None)
      Log every n examples (not currently used).
  
  Returns
  -------
  Tuple[List[int], List[int], List[int]]
      A tuple of train indices, valid indices, and test indices.
      Each indices is a list of integers.
docstr_tok: ["Splits","internal","compounds","into","train\/validation\/test","using","the","MaxMin","diversity","algorithm",".","Parameters","--","--","--","--","--","dataset",":","Dataset","Dataset","to","be","split",".","frac_train",":","float",",","optional","(","default","0.8",")","The","fraction","of","data","to","be","used","for","the","training","split",".","frac_valid",":","float",",","optional","(","default","0.1",")","The","fraction","of","data","to","be","used","for","the","validation","split",".","frac_test",":","float",",","optional","(","default","0.1",")","The","fraction","of","data","to","be","used","for","the","test","split",".","seed",":","int",",","optional","(","default","None",")","Random","seed","to","use",".","log_every_n",":","int",",","optional","(","default","None",")","Log","every","n","examples","(","not","currently","used",")",".","Returns","--","--","--","-","Tuple","[","List","[","int","]",",","List","[","int","]",",","List","[","int","]","]","A","tuple","of","train","indices",",","valid","indices",",","and","test","indices",".","Each","indices","is","a","list","of","integers","."]
code: def split(
      self,
      dataset: Dataset,
      frac_train: float = 0.8,
      frac_valid: float = 0.1,
      frac_test: float = 0.1,
      seed: Optional[int] = None,
      log_every_n: Optional[int] = None,
  ) -> Tuple[List[int], List[int], List[int]]:
      """
      Splits internal compounds into train/validation/test using the MaxMin diversity algorithm.
  
      Parameters
      ----------
      dataset: Dataset
          Dataset to be split.
      frac_train: float, optional (default 0.8)
          The fraction of data to be used for the training split.
      frac_valid: float, optional (default 0.1)
          The fraction of data to be used for the validation split.
      frac_test: float, optional (default 0.1)
          The fraction of data to be used for the test split.
      seed: int, optional (default None)
          Random seed to use.
      log_every_n: int, optional (default None)
          Log every n examples (not currently used).
  
      Returns
      -------
      Tuple[List[int], List[int], List[int]]
          A tuple of train indices, valid indices, and test indices.
          Each indices is a list of integers.
      """
      try:
          from rdkit import Chem, DataStructs
          from rdkit.Chem import AllChem
          from rdkit.SimDivFilters.rdSimDivPickers import MaxMinPicker
      except ModuleNotFoundError:
          raise ImportError(
              "This function requires RDKit to be installed."
          )
  
      np.testing.assert_almost_equal(
          frac_train + frac_valid + frac_test, 1.0
      )
      if seed is None:
          seed = random.randint(0, 2**30)
      np.random.seed(seed)
  
      num_datapoints = len(dataset)
  
      train_cutoff = int(frac_train * num_datapoints)
      valid_cutoff = int((frac_train + frac_valid) * num_datapoints)
  
      num_valid = valid_cutoff - train_cutoff
      num_test = num_datapoints - valid_cutoff
  
      all_mols = []
      for ind, smiles in enumerate(dataset.ids):
          all_mols.append(Chem.MolFromSmiles(smiles))
  
      fps = [
          AllChem.GetMorganFingerprintAsBitVect(x, 2, 1024)
          for x in all_mols
      ]
  
      def distance(i, j):
          return 1 - DataStructs.DiceSimilarity(fps[i], fps[j])
  
      picker = MaxMinPicker()
      testIndices = picker.LazyPick(
          distFunc=distance,
          poolSize=num_datapoints,
          pickSize=num_test,
          seed=seed,
      )
  
      validTestIndices = picker.LazyPick(
          distFunc=distance,
          poolSize=num_datapoints,
          pickSize=num_valid + num_test,
          firstPicks=testIndices,
          seed=seed,
      )
  
      allSet = set(range(num_datapoints))
      testSet = set(testIndices)
      validSet = set(validTestIndices) - testSet
  
      trainSet = allSet - testSet - validSet
  
      assert len(testSet & validSet) == 0
      assert len(testSet & trainSet) == 0
      assert len(validSet & trainSet) == 0
      assert (validSet | trainSet | testSet) == allSet
  
      return (
          sorted(list(trainSet)),
          sorted(list(validSet)),
          sorted(list(testSet)),
      )
  
imports: import inspect
  import itertools
  import logging
  import os
  import random
  import tempfile
  from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union
  import deepchem
  import numpy
  import pandas
  from deepchem.data import Dataset, DiskDataset
  from deepchem.utils import get_print_threshold
label_desc: Use image node_id 1 for calling the MaxMinSplitter obj's underlying member method code with example usage: obj.split(dataset, frac_train, frac_valid, frac_test, seed, log_every_n) and returns: sorted,  sorted,  sorted, unknown