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:
objectSample 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:
schema_sampler (SchemaSampler) – Dataset schema sampler.
dag_sampler (DAGSampler) – DAG sampler.
latent_channels (HP[int] | int) – Number of unobserved channels per node, in addition to channels assigned to feature and target columns.
root_sampler (RootSampler) – Sampler for initial values at nodes without parents.
random_fn (RandomFunction) – Random function for computing node values.
parent_merger (ParentMerger) – Rule for computing node values from multiple parents using
random_fn.numerical_converter (NumericalConverter | MixtureConverter[NumericalConverter]) – Converter to numerical column values, including regression targets. A mixture selects a converter per column.
categorical_converter (CategoricalConverter | MixtureConverter[CategoricalConverter]) – Converter to category indices, including classification targets. A mixture selects a converter per column.
transforms (Sequence[PriorTransform]) – Ordered dataset transforms after column conversion.
- sample(num_rows: int, *, schema: Schema | None = None, generator: Generator | None = None) tuple[TableTensor, TableTensor] | None#
Sample a synthetic dataset.
- Parameters:
- Returns:
Features of shape
[R, C]and targets of shape[R, 1], whereRis the row count andCis the feature count. Classification targets are categorical; regression targets are numerical. ReturnNoneif generation or a transform rejects the dataset.- Return type:
tuple[TableTensor, TableTensor] | None