Inferensys

Glossary

Do-Why Library

An open-source Python library by Microsoft for causal inference that provides a unified interface for modeling causal assumptions, identifying estimands, and estimating effects.
ML engineer working on model compression and quantization, laptop showing performance benchmarks, technical workspace.
Causal Inference Framework

What is Do-Why Library?

An open-source Python library by Microsoft that provides a unified four-step interface for causal inference: modeling assumptions, identifying estimands, estimating effects, and refuting results.

The Do-Why library is an open-source Python framework developed by Microsoft Research that formalizes causal inference into a structured, four-step workflow: modeling, identification, estimation, and refutation. It provides a unified interface that connects causal graphical models, such as Directed Acyclic Graphs, with a wide range of estimation methods, enabling analysts to explicitly encode domain knowledge as causal assumptions and systematically test them.

A key innovation of Do-Why is its automated refutation step, which subjects estimated causal effects to robustness checks like adding random common causes or using placebo treatments. This helps analysts distinguish genuine causal relationships from spurious correlations, making it a critical tool for tasks like Root Cause Identification Engine development and Causal Impact Analysis in complex systems.

CAUSAL INFERENCE LIBRARY

Core Capabilities of Do-Why

An open-source Python library by Microsoft that provides a unified interface for modeling causal assumptions, identifying estimands, and estimating effects using a four-step workflow.

01

Explicit Causal Modeling

Separates causal assumptions from data analysis by requiring users to explicitly encode domain knowledge as a Directed Acyclic Graph (DAG). This graph defines the causal relationships between variables—including confounders, mediators, and instruments—before any estimation occurs. The model step forces practitioners to declare their beliefs transparently, making the entire analysis auditable and debatable. Supports multiple model types including Structural Causal Models (SCM) and potential outcomes frameworks.

4-step
Workflow (Model, Identify, Estimate, Refute)
02

Automated Estimand Identification

Applies do-calculus and graphical criteria automatically to determine whether a causal effect can be estimated from observational data. The library inspects the user-provided DAG and applies rules like the backdoor criterion, front-door criterion, and instrumental variable identification to output a mathematical expression for the interventional distribution. This eliminates manual derivation errors and handles complex graphs where the identification path is non-obvious to human analysts.

3 rules
Do-Calculus Inference Engine
03

Multi-Method Estimation

Provides a unified interface to a wide range of estimation methods, allowing practitioners to switch between techniques without rewriting code. Supported methods include:

  • Linear regression and instrumental variable estimators
  • Propensity score matching and stratification
  • Inverse Probability of Treatment Weighting (IPTW)
  • Double Machine Learning for high-dimensional confounders
  • EconML integration for heterogeneous treatment effects Each estimator receives the same identified estimand, ensuring consistent inputs across methods.
10+
Built-in Estimators
04

Robustness Refutation Tests

Systematically stress-tests causal estimates to assess their sensitivity to unobserved confounding and model misspecification. Refutation methods include:

  • Random common cause: Adding a simulated confounder to see if the estimate changes
  • Placebo treatment: Replacing the treatment with an independent random variable
  • Data subset validation: Re-estimating on random subsets to check stability
  • Bootstrap refutation: Assessing estimate variance through resampling This step provides a quantitative confidence assessment that goes beyond p-values.
4 types
Refutation Methods
05

Counterfactual Prediction

Enables estimation of individual-level what-if scenarios using the three-step abduction-action-prediction process from structural causal models. Given observed outcomes, the library updates the noise distribution of exogenous variables (abduction), sets the treatment to a hypothetical value (action), and computes the resulting outcome (prediction). This supports use cases like identifying which specific shipments would have been delayed under a different routing policy.

3-step
Abduction-Action-Prediction
06

Ecosystem Interoperability

Integrates with the broader Python causal inference and machine learning ecosystem through standardized interfaces. Key integrations include:

  • EconML: Microsoft's library for heterogeneous treatment effect estimation using causal forests and meta-learners
  • Scikit-learn: Compatible with any sklearn-compatible model for nuisance function estimation
  • NetworkX: Graph construction and manipulation for DAG specification
  • Pyro: Probabilistic programming backend for Bayesian causal models This modularity allows practitioners to leverage state-of-the-art ML models as components within a rigorous causal framework.
4+
Major Library Integrations
CAUSAL INFERENCE CLARIFIED

Frequently Asked Questions

Clear, technically precise answers to the most common questions about Microsoft's Do-Why library for causal inference, designed for engineers and researchers moving beyond correlation to causation.

Do-Why is an open-source Python library developed by Microsoft Research that provides a unified, four-step framework for causal inference: modeling, identification, estimation, and refutation. It works by first encoding causal assumptions as a Directed Acyclic Graph (DAG) using the CausalModel interface. The library then automatically applies graph-based identification algorithms, such as the backdoor criterion and instrumental variable methods, to determine if a target causal estimand can be computed from available data. Do-Why separates the identification step from estimation, allowing users to plug in various estimation methods—from simple linear regression to advanced double machine learning and causal forest models—while maintaining a principled causal workflow. The final refutation step systematically tests the robustness of the estimated effect using placebo treatments, data subset validation, and sensitivity analysis for unobserved confounding.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.