causally.scm.scm.BaseStructuralCausalModel

class causally.scm.scm.BaseStructuralCausalModel(num_samples: int, graph_generator: GraphGenerator, noise_generator: Distribution, scm_context: SCMContext | None = None, seed: int | None = None)

Base abstract class for synthetic data generation.

Classes inheriting from BaseStructuralCausalModel must implement the method _sample_mechanism, specifying how to sample effects from parents and noise terms observtations.

Parameters:
  • num_samples (int) – Number of samples in the dataset.

  • graph_generator (GraphGenerator) – Random graph generator implementing the get_random_graph method.

  • noise_generator (Distribution) – Sampler of the noise random variables. It must be an instance of a class inheriting from causally.scm.noise.Distribution, implementing the sample method.

  • scm_context (SCMContext, default None) – SCMContext object specifying the modeling assumptions of the SCM. If None this is equivalent to an SCMContext object with no assumption specified.

  • seed (int, default None) – Seed for reproducibility. If None, then the random seed is not set.

Methods

sample()

Sample a dataset of observations.