CausalEGM.util.Base_sampler
- class CausalEGM.util.Base_sampler(x, y, v, batch_size=32, normalize=False, random_seed=123)[source]
Base data sampler.
- Parameters:
x – List or Numpy.ndarray bject denoting the treatment with length N or shape (N, 1) or (N, ).
y – List or Numpy.ndarray bject denoting the outcome with length N or shape (N, 1) or (N, ).
v – List or Numpy.ndarray bject denoting the covariates with length N or shape (N, v_dim).
batch_size – Int object denoting the batch size for mini-batch training. Default:
32.
Examples
>>> from CausalEGM import Base_sampler >>> import numpy as np >>> x = np.random.normal(size=(2000,)) >>> y = np.random.normal(size=(2000,)) >>> v = np.random.normal(size=(2000,100)) >>> ds = Base_sampler(x=x,y=y,v=v) >>> batch = ds.next_batch() # get a batch of data >>> data = ds.load_all() # get all data as a triplet
Methods
__init__(x, y, v[, batch_size, normalize, ...])create_idx_generator(sample_size[, random_seed])load_all()next_batch()