API reference

andrey.data.sample_scm#

andrey.data.sample_scm(*, graph='erdos_renyi', functional='linear', noise='gaussian', d, n, seed, density=4.0, scale='standardize', latents=0, dtype=<class 'numpy.float64'>, shuffle=True)[source]#

One-shot convenience: build an SCM from string axes and sample it.

Parameters:
  • graph (str) – Axis selectors; see graphs / functional / noise for the available names.

  • functional (str) – Axis selectors; see graphs / functional / noise for the available names.

  • noise (str) – Axis selectors; see graphs / functional / noise for the available names.

  • d (int) – Node count and sample count.

  • n (int) – Node count and sample count.

  • seed (int) – Root seed.

  • density (float) – Mean total degree (2 * |E| / d), for every graph. Each builder rounds it to the nearest value it can draw.

  • scale (str) – How the generated values are scaled; forwarded to SCM.sample(), which describes each mode. "standardize" z-scores the columns; "unitless" (linear functional, at most 1,000 nodes) gives every node variance 1 by its draw of weights and noise scales, with R^2-sortability near 0.5; "rescale" divides each node by its sample standard deviation as it is generated; "raw" keeps the generated values. Temporal functionals take "standardize" and "raw".

  • latents (int) – How many of the d nodes to hide as latent confounders, chosen among nodes with at least two children: data drops them, and the true graph lists them last. Temporal functionals take only 0.

  • dtype (DTypeLike) – Output dtype of the sampled data; forwarded to SCM.sample().

  • shuffle (bool) – Shuffle the column order with the true graph; forwarded to SCM.sample().

Return type:

CausalDataset