py-scm

A Python library for exact associational, interventional, and counterfactual reasoning in Gaussian Bayesian Belief Networks (BBNs) and linear-Gaussian structural causal models.

Current release: 1.0.0.

py-scm works from:

  • a directed acyclic graph

  • per-variable means

  • a covariance matrix

The reasoning surface is linear-Gaussian:

  • pquery() performs conditional multivariate-normal inference

  • iquery() computes exact post-intervention moments under do(...)

  • equery() computes exact causal-effect deltas between intervention endpoints

  • cquery() performs exact abduction-action-prediction when the factual world is fully observed

These methods return pandas objects by default. When pandas wrapping is not needed, set pandas=False to get raw NumPy-backed results with the same semantics.

These query types are regression-tested against closed-form linear-Gaussian oracles and benchmarked against R bnlearn on a benchmark-derived Gaussian suite that includes backdoor, mediation, joint-intervention, and collider-conditioned scenarios.

For synthetic benchmark, demo, or regression models, see BBN Generation for the built-in Gaussian BBN generators.

If you need the same exact Gaussian reasoning surface outside Python, see Native Ports for the maintained native and non-Python ports.

pyscm logo.

py-scm is released under the Apache-2.0 license.

Indices and tables

Citation

@misc{rocketvector_pyscm_2026,
title={PySCM},
url={https://pyscm.rocketvector.io},
author={Vang, Jee},
year={2026},
month={Apr}}