In industrial fluid systems, observational sensor data is often highly confounded. This project simulates a scenario where standard machine learning (Ordinary Least Squares regression) yields a physically impossible result due to an unobserved confounder (a Simpson's Paradox). We use Causal Inference (Inverse Probability Weighting) to recover the true laws of physics.
The synthetic data is generated using the Hagen-Poiseuille equation for steady, laminar flow of an incompressible Newtonian fluid through a cylindrical pipe:
To simplify the system, we define the geometric and fluid properties as a single term, Hydraulic Resistance (
Yielding the linear relationship:
System Setup: We simulate two pipes. Pipe A is narrow (high resistance). Pipe B is wide (low resistance).
A hidden bias is introduced into the operational data. The system operator preferentially routes hot fluid (low viscosity) through the narrow Pipe A, and cold fluid (high viscosity) through the wide Pipe B.
Viscosity is modeled as a function of temperature (
The operator's pipe selection (
Because temperature determines both the fluid viscosity (affecting pressure drop) and the pipe selection,
If an analyst ignores temperature and fits a standard regression model to find hydraulic resistance:
The model fails. Because
To recover the true physics, we map the causal graph:
We calculate a weight (
Applying these weights in a Weighted Least Squares (WLS) regression successfully breaks the spurious correlation, allowing us to mathematically recover the true, physical Hagen-Poiseuille resistance.
- Python 3.x
- NumPy / Pandas (Synthetic Data Generation)
- Statsmodels (OLS and WLS Regression)
- DoWhy / CausalML (Causal Graphing and Propensity Estimation)
Causal Inference & Simpson's Paradox
- Understanding Simpson’s Paradox - Judea Pearl (2014). UCLA Cognitive Systems Laboratory. This paper provides the foundational theory explaining why Simpson's Paradox is a causal, rather than purely statistical, phenomenon.
- Simpson's Paradox (Wikipedia) - A comprehensive overview of the paradox, its mathematical definition, and famous historical examples.
Mathematical Methodology
- The Central Role of the Propensity Score in Observational Studies for Causal Effects - Paul R. Rosenbaum & Donald B. Rubin (1983). Biometrika. The bedrock paper formalizing the propensity score and the mechanics behind Inverse Probability Weighting (IPW) used to correct the operator bias in this simulation.
Software & Tooling
- DoWhy: An End-to-End Library for Causal Inference - Amit Sharma, Emre Kiciman, et al. (2020). arXiv preprint. The academic foundation for the Microsoft DoWhy library, which was utilized to construct the causal Directed Acyclic Graph (DAG) and estimate the propensity scores.
Fluid Dynamics Ground Truth
- Fluid Mechanics - Frank M. White. McGraw-Hill Education. Used as the theoretical physical basis for generating the steady, laminar, and incompressible Hagen-Poiseuille pipe flow data.