SCMPrior#

class sdm.prior.tabular.SCMPrior(schema_sampler: SchemaSampler, dag_sampler: DAGSampler, latent_channels: HP[int] | int, root_sampler: RootSampler, random_fn: RandomFunction, parent_merger: ParentMerger, numerical_converter: NumericalConverter | MixtureConverter[NumericalConverter], categorical_converter: CategoricalConverter | MixtureConverter[CategoricalConverter], transforms: Sequence[PriorTransform] = ())#

Bases: object

Sample datasets from random structural causal models (SCMs).

Sample a directed acyclic graph and evaluate random functions from root to leaf. Nodes carry latent channels; converters map selected channels to feature and target columns and may update the values passed to child nodes. Apply dataset transforms to the resulting tables.

Parameters:
sample(num_rows: int, *, schema: Schema | None = None, generator: Generator | None = None) → tuple[TableTensor, TableTensor] | None#

Sample a synthetic dataset.

Parameters:
  • num_rows (int) – Number of rows in the dataset.

  • schema (Schema | None) – Schema to use instead of drawing from the schema sampler.

  • generator (Generator | None) – Pseudorandom generator.

Returns:

Features of shape [R, C] and targets of shape [R, 1], where R is the row count and C is the feature count. Classification targets are categorical; regression targets are numerical. Return None if generation or a transform rejects the dataset.

Return type:

tuple[TableTensor, TableTensor] | None