peal.data.dataset_generators.MNISTConfounderDatasetGenerator

class peal.data.dataset_generators.MNISTConfounderDatasetGenerator[source]

Bases: object

Two-digit MNIST subset with a red background as confounder.

Every digit image is resized to 32x32, tiled to RGB and its red channel is raised to a random background intensity; Confounder is 1 when that intensity is >= 128. Note the confounder is drawn independently of the digit, so the columns are not correlated by construction. A constant 8x8 central hint mask is written for every image.

Parameters:
  • dataset_name (str) – Output folder datasets/<dataset_name>.

  • mnist_dir (str) – Folder with one sub-folder of image files per digit.

  • digits (list of str) – Two digit folders; Feature is 1 for the second one.

Methods

generate_dataset

Write imgs/, masks/ and data.csv (ImgName, Feature, Confounder) into the dataset folder.

__init__(dataset_name, mnist_dir='datasets/mnist', digits=['0', '8'])[source]

Store the paths; nothing is written until generate_dataset.

generate_dataset()[source]

Write imgs/, masks/ and data.csv (ImgName, Feature, Confounder) into the dataset folder.

An existing folder is moved aside to <dataset_dir>_old_<timestamp> first.