class_docstr: Class for doing data splits by stratification on a single task.
  
  Examples
  --------
  >>> n_samples = 100
  >>> n_features = 10
  >>> n_tasks = 10
  >>> X = np.random.rand(n_samples, n_features)
  >>> y = np.random.rand(n_samples, n_tasks)
  >>> w = np.ones_like(y)
  >>> dataset = DiskDataset.from_numpy(np.ones((100,n_tasks)), np.ones((100,n_tasks)))
  >>> splitter = SingletaskStratifiedSplitter(task_number=5)
  >>> train_dataset, test_dataset = splitter.train_test_split(dataset)
class_docstr_tok: ["Class","for","doing","data","splits","by","stratification","on","a","single","task",".","Examples","--","--","--","--",">",">",">","n_samples","=","100",">",">",">","n_features","=","10",">",">",">","n_tasks","=","10",">",">",">","X","=","np.random.rand","(","n_samples",",","n_features",")",">",">",">","y","=","np.random.rand","(","n_samples",",","n_tasks",")",">",">",">","w","=","np.ones_like","(","y",")",">",">",">","dataset","=","DiskDataset.from_numpy","(","np.ones","(","(","100",",","n_tasks",")",")",",","np.ones","(","(","100",",","n_tasks",")",")",")",">",">",">","splitter","=","SingletaskStratifiedSplitter","(","task_number=5",")",">",">",">","train_dataset",",","test_dataset","=","splitter.train_test_split","(","dataset",")"]
docstr: Splits compounds into train/validation/test using stratified sampling.
  
  Parameters
  ----------
  dataset: Dataset
      Dataset to be split.
  frac_train: float, optional (default 0.8)
      Fraction of dataset put into training data.
  frac_valid: float, optional (default 0.1)
      Fraction of dataset put into validation data.
  frac_test: float, optional (default 0.1)
      Fraction of dataset put into test data.
  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[np.ndarray, np.ndarray, np.ndarray]
      A tuple of train indices, valid indices, and test indices.
      Each indices is a numpy array.
docstr_tok: ["Splits","compounds","into","train\/validation\/test","using","stratified","sampling",".","Parameters","--","--","--","--","--","dataset",":","Dataset","Dataset","to","be","split",".","frac_train",":","float",",","optional","(","default","0.8",")","Fraction","of","dataset","put","into","training","data",".","frac_valid",":","float",",","optional","(","default","0.1",")","Fraction","of","dataset","put","into","validation","data",".","frac_test",":","float",",","optional","(","default","0.1",")","Fraction","of","dataset","put","into","test","data",".","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","[","np.ndarray",",","np.ndarray",",","np.ndarray","]","A","tuple","of","train","indices",",","valid","indices",",","and","test","indices",".","Each","indices","is","a","numpy","array","."]
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[np.ndarray, np.ndarray, np.ndarray]:
      """
      Splits compounds into train/validation/test using stratified sampling.
  
      Parameters
      ----------
      dataset: Dataset
          Dataset to be split.
      frac_train: float, optional (default 0.8)
          Fraction of dataset put into training data.
      frac_valid: float, optional (default 0.1)
          Fraction of dataset put into validation data.
      frac_test: float, optional (default 0.1)
          Fraction of dataset put into test data.
      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[np.ndarray, np.ndarray, np.ndarray]
          A tuple of train indices, valid indices, and test indices.
          Each indices is a numpy array.
      """
      # JSG Assert that split fractions can be written as proper fractions over 10.
      # This can be generalized in the future with some common demoninator determination.
      # This will work for 80/20 train/test or 80/10/10 train/valid/test (most use cases).
      np.testing.assert_equal(frac_train + frac_valid + frac_test, 1.0)
      np.testing.assert_equal(
          10 * frac_train + 10 * frac_valid + 10 * frac_test, 10.0
      )
  
      if seed is not None:
          np.random.seed(seed)
  
      y_s = dataset.y[:, self.task_number]
      sortidx = np.argsort(y_s)
  
      split_cd = 10
      train_cutoff = int(np.round(frac_train * split_cd))
      valid_cutoff = int(np.round(frac_valid * split_cd)) + train_cutoff
  
      train_idx: np.ndarray = np.array([])
      valid_idx: np.ndarray = np.array([])
      test_idx: np.ndarray = np.array([])
  
      while sortidx.shape[0] >= split_cd:
          sortidx_split, sortidx = np.split(sortidx, [split_cd])
          shuffled = np.random.permutation(range(split_cd))
          train_idx = np.hstack(
              [train_idx, sortidx_split[shuffled[:train_cutoff]]]
          )
          valid_idx = np.hstack(
              [
                  valid_idx,
                  sortidx_split[shuffled[train_cutoff:valid_cutoff]],
              ]
          )
          test_idx = np.hstack(
              [test_idx, sortidx_split[shuffled[valid_cutoff:]]]
          )
  
      # Append remaining examples to train
      if sortidx.shape[0] > 0:
          np.hstack([train_idx, sortidx])
  
      return (train_idx, valid_idx, test_idx)
  
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 3 for calling the SingletaskStratifiedSplitter obj's underlying member method code with example usage: obj.split(dataset, frac_train, frac_valid, frac_test, seed, log_every_n) and returns: train_idx,  valid_idx,  test_idx