Skip to content

Single Concept Standard dataset

torchmil.datasets.SCStandardMILDataset

Bases: Dataset

Single-Concept Standard MIL Dataset. Implementation from Algorithm 1 in Reproducibility in Multiple Instance Learning: A Case For Algorithmic Unit Tests.

__init__(D, num_bags, B, pos_class_prob=0.5, train=True, seed=0)

Parameters:

  • D (int) –

    Dimensionality of the data.

  • num_bags (int) –

    Number of bags in the dataset.

  • B (int) –

    Number of negative instances in each bag.

  • pos_class_prob (float, default: 0.5 ) –

    Probability of a bag being positive.

  • seed (int, default: 0 ) –

    Seed for the random number generator.

__getitem__(index)

Parameters:

  • index (int) –

    Index of the bag to retrieve.

Returns:

  • bag_dict ( TensorDict ) –

    Dictionary containing the following keys:

    • X: Bag features of shape (bag_size, feat_dim).
    • Y: Label of the bag.
    • y_inst: Instance labels of the bag.