Explaining categorical feature interactions using graph covariance and LLMs

Cencheng Shen, Darren Edge, Jonathan Larson, Carey E. Priebe

TL;DR

This paper introduces a high-speed framework for uncovering and explaining hidden patterns in large-scale categorical datasets over time. By combining a computationally efficient "graph covariance" metric with the narrative power of Large Language Models (LLMs), the authors can detect significant feature interactions in seconds and automatically generate context-aware explanations for why those interactions occurred.

What Problem Does This Paper Address?

Modern datasets—especially in social sciences and public policy—are often "temporal and categorical." Think of a database of human trafficking cases where each entry has a timestamp and attributes like gender, citizenship, and type of exploitation.

Analyzing these datasets presents two major hurdles:

  1. The Computational Bottleneck: Traditional methods for detecting non-linear dependencies (like distance correlation or Hilbert-Schmidt Independence Criterion) are slow, often scaling at $O(n^2)$. On a dataset with hundreds of thousands of records, these can take hours or even days to run.
  2. The Interpretation Gap: Even if a statistical tool tells you that "Feature A" and "Feature B" became highly correlated in 2015, it won't tell you why. Bridging the gap between a statistical spike and a real-world geopolitical event usually requires weeks of manual research by domain experts.

Methods

The authors propose a multi-step pipeline designed for speed and interpretability:

  • Binarization: They first transform categorical features into binary variables using one-hot encoding.
  • Graph Covariance ($\Sigma_t$): Instead of using heavy $O(n^2)$ metrics, they use "graph covariance." For binary data, this is a consistent dependence measure that quantifies how much the joint probability of two features deviates from the product of their marginal probabilities. Crucially, this can be computed using fast matrix multiplication, resulting in a complexity of $O(np_1)$, where $n$ is the number of samples and $p_1$ is the number of binary features.
  • Significance Filtering: They derive a 95% significance level based on the Central Limit Theorem to identify two types of interactions:
  • Common Interactions ($\Delta_1$): Persistent trends that appear frequently over the entire timeline.
  • Spiked Interactions ($\Delta_2$): Sudden, sharp increases in dependence at specific moments.
  • LLM-Powered Narratives: The significant feature pairs, their timestamps, and the direction of the trend (positive or negative) are fed into an LLM (like GPT-4). The LLM is tasked with cross-referencing these data points with historical and geopolitical contexts to suggest potential real-world causes.

Datasets

The paper evaluates the method using two primary sources:

  1. Simulation Studies: A synthetic environment with eight binary features designed to exhibit various behaviors: independence, stable dependence, and shifting relationships (increasing, decreasing, or spiking).
  2. CTDC Global Synthetic Dataset: The primary real-world focus is the Counter Trafficking Data Collaborative (CTDC) dataset. It contains over 200,000 anonymized records of human trafficking cases spanning 2002 to 2022, featuring 26 categorical dimensions.

Key Insights and Ideas

  • Categorical Efficiency: The "aha moment" is that for binary/categorical data, you don't need the "universal" (and slow) dependence measures used for continuous data. Graph covariance provides a "consistent" measure (it converges to zero if and only if features are independent) while being orders of magnitude faster.
  • The LLM as a Research Assistant: The paper treats the LLM not just as a chatbot, but as a bridge to historical context. By providing the LLM with specific "data stories" (e.g., "There was a spike in trafficking between Myanmar and Indonesia in 2015"), the model can pinpoint events like the Rohingya crisis as a likely driver.
  • Handling Irregular Sampling: Unlike classical time-series analysis which expects data at regular intervals, this method handles "irregular" temporal data where multiple observations might share the same timestamp (e.g., many cases registered in the same year).

Key Results

  • Massive Speedup: The framework processed the entire CTDC dataset (200k+ records) in under 2 seconds. In comparison, "fast" distance correlation took hours, and other standard measures would have taken days.
  • Pattern Detection: In simulations, the method perfectly distinguished between stable, increasing, decreasing, and spiked dependencies, even when the signals were subtle.
  • Real-World Discovery: On the CTDC data, the tool identified well-known patterns (e.g., the strong link between "Sexual Exploitation" and "Women") but also flagged more nuanced shifts, such as a significant drop in reported cases between the Philippines and the USA in 2016. The LLM successfully attributed this to a combination of stricter migration controls and improved anti-trafficking measures in both countries.

Limitations and Future Work

  • LLM Reliability: The authors acknowledge that LLM-generated explanations are "potential data stories" and require validation from domain experts, as LLMs can occasionally hallucinate or oversimplify complex geopolitical issues.
  • Pairwise Limits: The current method focuses on interactions between pairs of features. The authors suggest that future work could extend this to "triplet" interactions (3-way dependencies).
  • Continuous Data: While designed for categorical data, the authors note that continuous features could be integrated in the future by discretizing them into quantiles (e.g., turning "Age" into "Age Groups").
  • Prompt Engineering: Future versions could improve accuracy by feeding more granular contextual information into the LLM prompts.

Summary updated

BibTeX
@article{shen2026explaining,
  author = {Cencheng Shen and Darren Edge and Jonathan Larson and Carey E. Priebe},
  title = {{Explaining categorical feature interactions using graph covariance and LLMs}},
  journal = {Appl. Netw. Sci.},
  year = {2026},
  doi = {10.1007/s41109-025-00770-3},
}
Figure