Skip to content

Latest commit

 

History

History
executable file
·
63 lines (52 loc) · 3.02 KB

File metadata and controls

executable file
·
63 lines (52 loc) · 3.02 KB

CausalLab — Interactive Causal Inference & Discovery Laboratory

Vision

The first interactive web laboratory for Judea Pearl's causal inference framework. Learn, visualize, and experiment with structural causal models, do-calculus, causal discovery algorithms, and counterfactual reasoning — all in-browser with zero dependencies.

Why Now

  • MIT Technology Review 2026 lists "World Models" as #1 AI trend — causal reasoning is the backbone
  • Causal AI is the frontier connecting AI safety, scientific reasoning, and robust decision-making
  • No comprehensive interactive web lab exists for this deeply mathematical field
  • Pearl's Ladder of Causation (Association → Intervention → Counterfactuals) maps perfectly to interactive modules

6 Modules

1. SCM Builder (Structural Causal Model)

  • Drag-and-drop DAG editor with nodes and directed edges
  • Define structural equations for each variable (e.g., Y := 2*X + U_Y)
  • Visualize data generation from the SCM
  • Identify paths, d-separation, conditional independencies
  • Color-code: confounders, mediators, colliders

2. do-Calculus Engine

  • Pearl's 3 rules of do-calculus with step-by-step derivations
  • Input: P(Y|do(X)) queries on a user-defined DAG
  • Visualize graph surgery (removing incoming edges for do-operator)
  • Show back-door criterion, front-door criterion, IV identification
  • Animate each derivation step

3. Causal Discovery Algorithms

  • PC Algorithm: constraint-based, starts with complete graph, removes edges via conditional independence
  • Run on simulated data with adjustable sample size & significance level
  • Visualize the skeleton → v-structures → orientation rules pipeline
  • Compare true DAG vs discovered DAG with metrics (SHD, precision, recall)

4. Simpson's Paradox Explorer

  • Classic Berkeley admissions example + custom datasets
  • Toggle between marginal and conditional views
  • Show how confounding reverses apparent relationships
  • Interactive: change confounder strength and watch the paradox appear/disappear

5. Instrumental Variables Lab

  • Visual IV identification on DAGs
  • 2SLS (Two-Stage Least Squares) estimation walkthrough
  • Weak instruments: show how weak IVs inflate variance
  • Interactive: adjust instrument strength, sample size, confounding

6. Counterfactual Reasoning (Pearl's Ladder Rung 3)

  • Twin network model visualization
  • Compute P(Y_x|X=x', Y=y') — probabilities of causation
  • PNS (Probability of Necessity and Sufficiency)
  • Interactive: "Would the patient have recovered if given the treatment?" scenarios

Tech Stack

  • Single HTML file, zero dependencies
  • Canvas-based DAG rendering with force-directed layout
  • Pure JS causal graph algorithms (d-separation, topological sort, path enumeration)
  • CSS Grid layout with dark theme
  • Embedded statistical computations (regression, chi-squared, correlation)

Design

  • Dark theme (#0a0a0f background, cyan #00d4ff accents)
  • Module tabs at the top
  • Each module: left panel (controls/params), center (main visualization), right panel (info/derivation)
  • Responsive, works on desktop