dotime.TemporalSCM
- class dotime.TemporalSCM(dag, mechanisms, noise, device=device(type='cpu'), dtype=torch.float32)[source]
Bases:
objectTemporal Structural Causal Model with time-stepped forward simulation.
Extends Do-PFN’s SCM to support temporal dependencies with lags.
- Parameters:
- __init__(dag, mechanisms, noise, device=device(type='cpu'), dtype=torch.float32)[source]
- Parameters:
dag (TemporalDAG) – Temporal DAG with instantaneous and lagged edges.
mechanisms (Dict[str, TemporalMechanism]) – Mechanisms for each variable.
noise (Dict[str, DistributionSampler]) – Noise distributions for each variable.
device (torch.device) – Device for computation.
dtype (torch.dtype) – Data type for computation.
Methods
__init__(dag, mechanisms, noise[, device, dtype])sample_interventional(T, intervention[, ...])Sample interventional data from the temporal SCM.
sample_observational(T[, burn_in, generator])Sample observational data from the temporal SCM.
- sample_observational(T, burn_in=50, generator=None)[source]
Sample observational data from the temporal SCM.
- Parameters:
T (int) – Length of time series to generate (after burn-in).
burn_in (int) – Number of burn-in steps to discard.
generator (torch.Generator, optional) – RNG for reproducibility.
- Return type:
- Returns:
torch.Tensor – Time series data of shape (T, N) where N is number of variables.
- sample_interventional(T, intervention, burn_in=50, generator=None)[source]
Sample interventional data from the temporal SCM.
- Parameters:
T (int) – Length of time series to generate (after burn-in).
intervention (InterventionSpec) – Intervention specification.
burn_in (int) – Number of burn-in steps to discard.
generator (torch.Generator, optional) – RNG for reproducibility.
- Return type:
- Returns:
torch.Tensor – Time series data of shape (T, N) under intervention.