chemprop.data.samplers#

Module Contents#

Classes#

SeededSampler

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

ClassBalanceSampler

A ClassBalanceSampler samples data from a MolGraphDataset such that

class chemprop.data.samplers.SeededSampler(N, seed)[source]#

Bases: torch.utils.data.Sampler

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

Parameters:
  • N (int)

  • seed (int)

__iter__()[source]#

an iterator over indices to sample.

Return type:

Iterator[int]

__len__()[source]#

the number of indices that will be sampled.

Return type:

int

class chemprop.data.samplers.ClassBalanceSampler(Y, seed=None, shuffle=False)[source]#

Bases: torch.utils.data.Sampler

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

Parameters:
  • dataset (MolGraphDataset) – the dataset from which to sample

  • seed (int) – the random seed to use for shuffling (only used when shuffle is True)

  • shuffle (bool, default=False) – whether to shuffle the data during sampling

  • Y (numpy.ndarray)

__iter__()[source]#

an iterator over indices to sample.

Return type:

Iterator[int]

__len__()[source]#

the number of indices that will be sampled.

Return type:

int