class_docstr: Convenience class to let singletask models be fit on multitask data.
  
  This wrapper class groups a set of singletask `SklearnModel` objects to
  create a multitask model. This class exists primarily to facilitate
  benchmarking.
  
  Note
  ----
  This current implementation is only functional for sklearn models.
class_docstr_tok: ["Convenience","class","to","let","singletask","models","be","fit","on","multitask","data",".","This","wrapper","class","groups","a","set","of","singletask","`","SklearnModel","`","objects","to","create","a","multitask","model",".","This","class","exists","primarily","to","facilitate","benchmarking",".","Note","--","--","This","current","implementation","is","only","functional","for","sklearn","models","."]
docstr: Transforms a multitask dataset to a collection of singletask datasets.
docstr_tok: ["Transforms","a","multitask","dataset","to","a","collection","of","singletask","datasets","."]
code: def _to_singletask(dataset, task_dirs):
      """Transforms a multitask dataset to a collection of singletask datasets."""
      tasks = dataset.get_task_names()
      assert len(tasks) == len(task_dirs)
      logger.info(
          "Splitting multitask dataset into singletask datasets"
      )
      task_datasets = [
          DiskDataset.create_dataset(
              [], task_dirs[task_num], [task.item()]
          )
          for (task_num, task) in enumerate(tasks)
      ]
      # task_metadata_rows = {task: [] for task in tasks}
      for shard_num, (X, y, w, ids) in enumerate(dataset.itershards()):
          logger.info("Processing shard %d" % shard_num)
          for task_num, task in enumerate(tasks):
              logger.info("\tTask %s" % task)
              if len(w.shape) == 1:
                  w_task = w
              elif w.shape[1] == 1:
                  w_task = w[:, 0]
              else:
                  w_task = w[:, task_num]
              y_task = y[:, task_num]
  
              # Extract those datapoints which are present for this task
              X_nonzero = X[w_task != 0]
              num_datapoints = X_nonzero.shape[0]
              y_nonzero = np.reshape(
                  y_task[w_task != 0], (num_datapoints, 1)
              )
              w_nonzero = np.reshape(
                  w_task[w_task != 0], (num_datapoints, 1)
              )
              ids_nonzero = ids[w_task != 0]
  
              task_datasets[task_num].add_shard(
                  X_nonzero, y_nonzero, w_nonzero, ids_nonzero
              )
  
      return task_datasets
  
file_path: deepchem/deepchem/models/multitask.py
imports: import os
  import numpy
  import shutil
  import logging
  from deepchem.models import Model
  from deepchem.data import DiskDataset
  from deepchem.trans import undo_transforms
label_desc: Use image node_id 3 for calling the SingletaskToMultitask obj's underlying member method code with example usage: obj._to_singletask(dataset, task_dirs) and returns: task_datasets