---
title: 'REX: Explainable Causal Discovery'
url: https://www.emergentmind.com/topics/rex-839ecb6c-19d0-4b1d-9e32-fe61cbab2022
type: topic
---

# REX: Explainable Causal Discovery

Rex, in contemporary machine-learning research, commonly denotes **REX**, a causal-discovery method that leverages machine-learning models and Shapley-value explainability to infer directed acyclic graphs (DAGs) from purely observational data. It was introduced to address the claim that no causal discovery methods currently incorporate explainability into their models to derive causal graphs, and it is designed to identify and interpret significant causal relationships among continuous variables while minimizing false positive predictions. In this formulation, REX bridges predictive modeling and causal inference by coupling supervised regressors with explainability and additive-noise-based edge orientation [2501.12706].

## 1. Scope and problem formulation

REX addresses **observational causal discovery**: given \(m\) i.i.d. samples of \(p\) continuous variables \(\mathbf X = \{X_1,\dots,X_p\}\) drawn from an unknown joint distribution, infer the underlying causal DAG \(\mathcal G=(V,E)\), where each directed edge \(X_j\!\to\!X_i\) indicates a direct causal influence. The framework is explicitly positioned against classical methods such as PC, GES, LiNGAM, CAM, and NOTEARS, which are described as relying on strong parametric assumptions, struggling with high-dimensional nonlinearity, or producing “black-box” structures difficult to interpret [2501.12706].

The central idea is to use predictive models not merely as function approximators, but as instruments for causal-structure recovery. For each target variable \(X_i\), REX trains regressors on the remaining variables and then uses Shapley-value explainability to isolate features that are consistently influential. These candidate parent sets are aggregated through bootstrapping into a graph skeleton, after which edge directions are inferred through Additive Noise Model (ANM) tests. The resulting pipeline is intended to recover true causal structure while maintaining a strong bias against spurious edge inclusion.

REX is formulated for **continuous tabular data** and is evaluated in both synthetic structural-equation settings and a real biological signaling dataset. Its public implementation is available at `https://github.com/renero/causalgraph`, together with synthetic dataset generators, Sachs preprocessing, the full implementation, and notebooks reproducing the experiments.

## 2. Formal basis: DAGs, SEMs, and Shapley values

The framework assumes the standard language of causal graphical models. A DAG consists of nodes \(V=\{X_1,\dots,X_p\}\) and edges \(E\subset V\times V\), with no directed cycles. Under the **Causal Markov Condition**, the joint distribution factorizes as

\[
P(X_1,\dots,X_p)\;=\;\prod_{i=1}^p P\bigl(X_i\mid \mathrm{pa}(i,\mathcal G)\bigr).
\]

REX also adopts **Faithfulness**, namely that all and only the conditional independencies entailed by \(\mathcal G\) appear in \(P\). The data-generating process is described through a **Structural Equation Model (SEM)** of the form

\[
X_i \;=\; f_i\bigl(X_{\mathrm{pa}(i)},\,\varepsilon_i\bigr),\quad \varepsilon_i\sim\mathcal N(0,1),
\]

with independent noise terms [2501.12706].

Its distinctive component is the use of **Shapley values** from cooperative game theory as a proxy for conditional dependence structure. For a target \(X_i\) and feature set \(F=\{X_j:\,j\neq i\}\), the Shapley value for \(X_j\) is

\[
\phi_j
= \sum_{S\subseteq F\setminus\{X_j\}}
\frac{|S|!\,(|F|-|S|-1)!}{|F|!}
\Bigl[\hat f(S\cup\{X_j\}) - \hat f(S)\Bigr].
\]

The marginal term \(\delta_{j,S}=\hat f(S\cup\{X_j\})-\hat f(S)\) is linked to conditional independence through the statement that \(\delta_{j,S}=0\) if and only if \(X_i\perp\!\!\!\perp X_j\mid S\). Aggregating over coalitions yields

\[
\phi_j \approx \overline{\delta_j}\;\sum_{S} w(S)\,I_{j,S}
= \overline{\delta_j}\;\Pr_{\!w}\bigl(X_i\not\perp\!\!\!\perp X_j\mid S\bigr),
\]

so that \(\phi_j\) is proportional to both the strength and the Shapley-weighted probability of conditional dependence. In effect, REX uses feature attribution not simply as post-hoc interpretability, but as a mechanism for narrowing the causal search to variables that repeatedly contribute predictive information.

## 3. Algorithmic pipeline

REX proceeds in three phases. The first is **model training**. For each variable \(X_i\), it trains two regressors \(\hat f_i\): a **Deep Feed-forward Network (DFN)** with additive uniform noise input \(\varepsilon\), and **Gradient-Boosting Trees (GBT, XGBoost)**. Hyperparameters are tuned via a **Tree-structured Parzen Estimator (TPE)** on an 80/20 split, optimizing mean squared error.

The second phase is **bootstrapped parent selection**. For \(t=1,\dots,T\), typically \(T=100\), REX samples a bootstrap subset \(\mathbf X^{(t)}\). For each target \(X_i\), it computes interventional SHAP values \(\Phi^{(i)}=\{\phi_j\}_{j\neq i}\), using **GradientExplainer** for DFN and **TreeExplainer** for GBT. It then clusters the SHAP values with **DBSCAN** to separate influential features from non-influential ones. The parent-selection routine dynamically reduces \(\varepsilon\) until DBSCAN yields more than one cluster, and returns the cluster with highest average \(\phi\) as \(pa(X_i)\). Each selected parent increments an adjacency matrix \(A\in\mathbb R^{p\times p}\); after \(T\) iterations, \(A\) is normalized by \(T\) and thresholded by a frequency cutoff \(\tau\) to produce an undirected skeleton [2501.12706].

The third phase is **edge orientation and cycle removal**. For each undirected edge \(\{X_i,X_j\}\) in the skeleton, REX fits two regressions under an ANM, for example with a Gaussian Process or GAM,

\[
X_i = g(X_j)+\eta,\quad X_j = h(X_i)+\xi,
\]

and tests residual–predictor independence with **HSIC**. The accepted direction is the one whose residuals are independent. The DFN-based and GBT-based DAGs are then unioned to capture any edge detected by either model. If cycles or bidirectional edges remain, REX computes a **SHAP discrepancy**

\[
\delta^{(i)}_j
= 1 \;-\; R^2\bigl(X_i,\phi_j\bigr)
= \frac{\sum_k(x_{k,i}-\varphi_{k,j})^2}{\sum_k(x_{k,i}-\overline X_i)^2},
\]

and iteratively reverses or drops the edge with highest \(\delta\) until acyclicity is achieved. This cycle-resolution procedure is one of the framework’s interpretability-driven design choices: edge retention is tied to the agreement between observed target variation and the attributed explanatory pattern.

## 4. Empirical evaluation

The synthetic evaluation uses **five families of generative SEMs**—linear, polynomial, sigmoid-additive, Gaussian-additive, and Gaussian-mixed—following the cited prior work. For each family, 10 random DAGs are generated with \(p\in\{10,15,20,25\}\) nodes and \(m=500\) samples, giving 200 datasets in total. The real-data evaluation uses the **Sachs single-cell protein-signaling dataset** with \(p=11\) and \(m=7466\), together with known tiered prior constraints. Baselines are **PC, FCI, GES, LiNGAM, NOTEARS, and CAM**, with default settings except that the NOTEARS threshold is tuned. The reported metrics are true and false positives and negatives with orientation, **precision**, **recall**, **\(F_1\)**, **Structural Hamming Distance (SHD)**, and **Structural Intervention Distance (SID)**. The implementation is reported on an **Apple M2 Pro, 32 GB RAM, no parallelization** [2501.12706].

On synthetic benchmarks with \(p=10\)–25, REX achieves **median \(F_1>0.7\) for \(p\le20\)** and outperforms all compared methods in \(F_1\) and precision. SHD and SID remain low and are often the lowest median. Computational time grows roughly quadratically in \(p\), with SHAP identified as the dominant cost.

On the Sachs dataset, REX reports **Precision = 0.952, Recall = 0.471, \(F_1 = 0.629\)**, with **SHD = 9** and **SID = 39**. It is stated to recover almost no false edges and to correctly orient key signaling relationships with no incorrect edges. The same evaluation reports that it outperforms **PC (\(F_1 = 0.376\))**, **FCI (0.516)**, **GES (0.273)**, **LiNGAM (0.134)**, **NOTEARS (0.270)**, and **CAM (0.353)**. The emphasis of these results is not merely higher aggregate score, but a particular operating point characterized by very high precision and limited false-positive structure.

## 5. Interpretability, robustness, and operational constraints

The principal stated advantages of REX are **high precision**, **interpretability**, **model-agnosticism**, and **robustness**. High precision is attributed to the combination of robust Shapley-driven parent selection and bootstrapping. Interpretability arises because every edge is backed by quantitative feature-attribution evidence \((\phi_j)\) and discrepancy measures. Model-agnosticism follows from the claim that any regressor with SHAP support can be plugged in. Robustness is associated with combining DFN and GBT so that complementary nonlinearities can be captured [2501.12706].

The limitations are equally explicit. First, the computational cost of SHAP grows exponentially in feature count, which is mitigated by sampling and interventional explainers but remains heavy for \(p\gg100\). Second, recall can be moderate in very dense graphs, described as a trade-off for high precision. Third, multicollinearity may blur Shapley contributions; this is addressed partially via interventional explainers but remains an open challenge.

Practical guidance is given in complexity and hyperparameter form. The overall complexity is described as roughly

\[
O\bigl(p\,(T\cdot(\mathrm{TrainCost}+\mathrm{SHAPcost}))+p^2\cdot\mathrm{ANMcost}\bigr).
\]

In practice, \(T=100\) bootstraps and interventional SHAP strike a balance between accuracy and speed. Additional stated settings include bootstrap sample fraction \(\ge 1-q^{1/r}\) with \(q=0.01\), DBSCAN minimum cluster size \(=2\), dynamically reduced \(\varepsilon\) until at least two clusters, adjacency threshold \(\tau\) filtering edges appearing in fewer than 20–30% of iterations, DFN architectures with 3–5 hidden layers and ReLU, noise input \(\mathrm{Uniform}(0,1)\), and GBT with XGBoost default learning rate \(0.3\) and max depth \(6\).

The future-work directions listed for REX are approximate SHAP for scalability, incorporation of Lasso- or CatBoost-based regressors, extension to out-of-distribution settings, refinement of parent selection beyond DBSCAN, and acceleration through GPU or distributed computing. A plausible implication is that the present framework is best understood as a high-precision, interpretation-oriented causal-discovery system rather than a general-purpose large-scale graph learner.

## 6. Disambiguation and related uses of the name

The term **Rex**, **REX**, or **REx** is strongly overloaded across arXiv and adjacent research domains. In machine learning alone, **“Out-of-Distribution Generalization via Risk Extrapolation (REx)”** defines REx as a robust-optimization principle that reduces variance of risk across training domains [2003.00688], whereas **“REX: Rapid Exploration and eXploitation for AI Agents”** uses REX for an LLM-agent framework based on UCB-style exploration and external reward bookkeeping [2307.08962]. In explainable medical imaging, **“3D ReX: Causal Explanations in 3D Neuroimaging Classification”** denotes a post-hoc actual-causality method for responsibility maps in stroke detection [2502.12181], and **“ReX-MLE: The Autonomous Agent Benchmark for Medical Imaging Challenges”** denotes a benchmark for autonomous coding agents on medical-imaging competitions [2512.17838]. In vision-language modeling, **“Rex-Thinker: Grounded Object Referring via Chain-of-Thought Reasoning”** refers to a referring-expression model trained with CoT supervision and GRPO [2506.04034].

Outside that cluster, the same label appears in knowledge-graph search, rule extraction, astronomy, and combinatorial game theory. **“REX: Explaining Relationships between Entity Pairs”** introduces a knowledge-base system for enumerating and ranking minimal relationship explanations [1111.7170]. **“REx: An Efficient Rule Generator”** names an ANN rule-extraction algorithm [1009.4988]. In astrophysics, **REX** is a catalogue of Radio-Emitting X-ray sources and **Te-REX** is a TeV-emitting candidate sample derived from it [1912.07613], while **T-ReX** abbreviates **“The Tarantula -- Revealed by X-rays”** [2403.16944]. In game theory, **Rex** denotes reverse Hex, and **Rex+** is its multi-stone-turn variant [2606.02468].

This suggests that the meaning of “Rex” is domain-dependent and that technical discussion requires immediate disambiguation. In current causal-discovery literature, however, the term most specifically denotes the explainability-driven DAG-learning framework introduced in 2025 [2501.12706].

Source: https://www.emergentmind.com/topics/rex-839ecb6c-19d0-4b1d-9e32-fe61cbab2022