lightning_uq_box.datamodules#

Toy Datamodules#

class lightning_uq_box.datamodules.ToyHeteroscedasticDatamodule(x_min: int | float = -4, x_max: int | float = 4, n_points: int = 250, batch_size: int = 100, test_fraction: float = 0.2, val_fraction: float = 0.1, calib_fraction: float = 0.4, generate_y: Callable = <function noisy_sine>, noise_seed: int = 42, split_seed: int = 42, invert: bool = False)[source]#

Implement Toy Dataset with heteroscedastic noise.

__init__(x_min: int | float = -4, x_max: int | float = 4, n_points: int = 250, batch_size: int = 100, test_fraction: float = 0.2, val_fraction: float = 0.1, calib_fraction: float = 0.4, generate_y: Callable = <function noisy_sine>, noise_seed: int = 42, split_seed: int = 42, invert: bool = False) None[source]#

Define a heteroscedastic toy regression dataset.

Inspired by (https://mapie.readthedocs.io/en/latest/examples_regression/ 1-quickstart/plot_heteroscedastic_1d_data.html#sphx-glr-examples- regression-1-quickstart-plot-heteroscedastic-1d-data-py)

Split n_points data points into train, validation and test set. We provide the following arrays: X_<type>, Y_<type>, where <type> is one of:

  • all: train + val + test

  • train: all - test - val

  • test: see test_fraction

  • val: validation, see val_fraction

  • calib: calibration, see calib_fraction

  • gtext: noise-free ground truth on extended x-axis

X and Y have shape (n_points_{type}, 1).

Parameters:
  • x_min – Minimum value of x range

  • x_max – Maximum value of x range

  • n_points – Number of train + test + validation points

  • batch_size – batch size for data loader

  • test_fraction – fraction of n_points for test set

  • val_fraction – fraction of n_points for validation set

  • calib_fraction – fraction of n_points for calibration set will be split from validation set and necessary for conformal prediction

  • generate_y – ground truth function with noise option, must have signature f(x, noise: bool)

  • noise_seed – random seed for x points positions and y noise

  • split_seed – random seed for train/test/val split

  • invert – whether to model the inverse problem, swaps X and Y in the DataLoader and variables

train_dataloader() DataLoader[source]#

Return train dataloader.

val_dataloader() DataLoader[source]#

Return val dataloader.

calib_dataloader() DataLoader[source]#

Return calibration dataloader.

test_dataloader() DataLoader[source]#

Return test dataloader.

gt_dataloader() DataLoader[source]#

Return test dataloader.

Image Regression Datamodules#

class lightning_uq_box.datamodules.ToyImageRegressionDatamodule(num_samples: int = 4, batch_size: int = 10)[source]#

Toy Image Regression Datamodule for Testing.

__init__(num_samples: int = 4, batch_size: int = 10) None[source]#

Initialize a new instance of Toy Image Regression Datamodule.

Parameters:
  • batch_size – batch size

  • num_samples – number of samples in each split

  • batch_size – int = 10

train_dataloader() DataLoader[source]#

Return Train Dataloader.

val_dataloader() DataLoader[source]#

Return Val Dataloader.

calib_dataloader() DataLoader[source]#

Return Calib Dataloader.

test_dataloader() DataLoader[source]#

Return Test Dataloader.