TabularDiffusion

Guide & worked example · Source

TabularDiffusion(
    hidden_dims=(128, 128, 128),
    time_dim=32,
    n_timesteps=100,
    beta_start=0.0001,
    beta_end=0.02,
    batch_size=128,
    max_steps=1000,
    lr=0.001,
    dropout=0.0,
    seed=None,
    device=None,
)

Small DDPM-style diffusion model for continuous tabular rows.

Attributes

Name Description
batch_size
beta_end
beta_start
device
dropout
hidden_dims
history
lr
max_steps
n_timesteps
params
seed
time_dim

Methods

Name Description
fit Fit a noise-prediction network with a discrete Gaussian schedule.
sample Generate rows by reversing the fitted discrete noise schedule.
summary Print a summary of the model results.
to Move all model parameters to specified device.

fit

TabularDiffusion.fit(X, context=None)

Fit a noise-prediction network with a discrete Gaussian schedule.

Parameters

Name Type Description Default
X array-like of shape (n_rows, n_features) Continuous numeric rows on the desired training scale. Converted to float32; there is no automatic categorical likelihood. required
context array-like of shape (n_rows, n_context) Conditioning covariates aligned with X. None

Returns

Name Type Description
TabularDiffusion Self, with denoiser, schedule and mean-squared noise-loss history.

sample

TabularDiffusion.sample(n, context=None)

Generate rows by reversing the fitted discrete noise schedule.

Parameters

Name Type Description Default
n int Number of requested rows. required
context array-like of shape (n, n_context) One context row per draw, in the representation used for fitting. None

Returns

Name Type Description
torch.Tensor Detached CPU tensor of shape (n, n_features), on training scale.

Notes

Sampling uses beta_t variance and no final-step noise. It starts from a standard Gaussian; a schedule that leaves substantial signal at its terminal step makes that initialization a poor approximation.

summary

TabularDiffusion.summary()

Print a summary of the model results.

to

TabularDiffusion.to(device)

Move all model parameters to specified device.

Parameters

Name Type Description Default
device torch.device or str Target device (‘cuda’, ‘cpu’, etc.) required

Returns

Name Type Description
BaseEstimator Self for method chaining