chemprop.data.samplers
======================

.. py:module:: chemprop.data.samplers


Classes
-------

.. autoapisummary::

   chemprop.data.samplers.SeededSampler
   chemprop.data.samplers.ClassBalanceSampler


Module Contents
---------------

.. py:class:: SeededSampler(N, seed)

   Bases: :py:obj:`torch.utils.data.Sampler`


   A :class`SeededSampler` is a class for iterating through a dataset in a randomly seeded
   fashion


   .. py:attribute:: idxs


   .. py:attribute:: rg


   .. py:method:: __iter__()

      an iterator over indices to sample.



   .. py:method:: __len__()

      the number of indices that will be sampled.



.. py:class:: ClassBalanceSampler(Y, seed = None, shuffle = False)

   Bases: :py:obj:`torch.utils.data.Sampler`


   A :class:`ClassBalanceSampler` samples data from a :class:`MolGraphDataset` such that
   positive and negative classes are equally sampled

   :param dataset: the dataset from which to sample
   :type dataset: MolGraphDataset
   :param seed: the random seed to use for shuffling (only used when `shuffle` is `True`)
   :type seed: int
   :param shuffle: whether to shuffle the data during sampling
   :type shuffle: bool, default=False


   .. py:attribute:: shuffle
      :value: False



   .. py:attribute:: rg


   .. py:attribute:: pos_idxs


   .. py:attribute:: neg_idxs


   .. py:attribute:: length


   .. py:method:: __iter__()

      an iterator over indices to sample.



   .. py:method:: __len__()

      the number of indices that will be sampled.



