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.
Glossary
Do-Why Library

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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
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.
Related Terms
Core concepts and methods that form the foundation of the DoWhy library's unified causal inference workflow.
Structural Causal Model (SCM)
The formal backbone of DoWhy's modeling step. An SCM defines causal relationships using structural equations that represent the data-generating mechanism. DoWhy uses SCMs to encode domain knowledge, specifying how each variable is determined by its direct causes and an independent exogenous noise term. This allows the library to mathematically distinguish between observational and interventional distributions.
Directed Acyclic Graph (DAG)
The visual and computational input to DoWhy's CausalModel. A DAG encodes causal assumptions as a graph where nodes are variables and directed edges represent direct causal effects, with no feedback loops. DoWhy uses the DAG to automatically apply graphical criteria like the backdoor criterion and front-door criterion during the identification step, determining which variables must be controlled to estimate a target causal effect.
Do-Calculus
A set of three inference rules developed by Judea Pearl that DoWhy leverages internally. Do-calculus transforms interventional probability distributions—expressions containing the do() operator—into standard observational probabilities. This is the mathematical engine that enables DoWhy's identification step to determine if a causal query can be answered from available data, even when simple covariate adjustment is insufficient.
Counterfactual Reasoning
The fourth and most granular step in DoWhy's workflow. Counterfactual analysis estimates what would have happened to a specific unit's outcome if its treatment had been different, given what actually occurred. DoWhy implements this through structural equation models to answer 'what-if' questions at the individual level—for example, attributing a specific supply chain delay to a particular supplier failure rather than to concurrent weather events.
Refutation Methods
A critical validation step unique to DoWhy's workflow. After estimating a causal effect, DoWhy applies robustness checks to stress-test assumptions:
- Placebo Treatment: Replaces the real treatment with an independent random variable to verify the estimate drops to zero
- Random Common Cause: Adds an unobserved confounder to assess sensitivity
- Data Subset Validation: Re-estimates on random subsets to check stability
- Bootstrap Refutation: Uses resampling to compute confidence intervals
Causal Discovery Algorithms
Methods that DoWhy integrates when a pre-specified DAG is unavailable. These algorithms infer causal structures directly from observational data by testing conditional independencies. DoWhy supports constraint-based algorithms like the PC algorithm and score-based methods, allowing users to bootstrap a plausible causal graph from raw data before proceeding through the standard identify-estimate-refute pipeline.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us