NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Contrastive Mixture of Posteriors for Counterfactual Inference, Data Integration and Fairness

Adam Foster, Árpi Vezér, Craig A. Glastonbury, Páidí Creed, Samer Abujudeh, Aaron Sim

Introduction

The authors introduce Contrastive Mixture of Posteriors (CoMP), a novel method for learning latent representations that are strictly independent of specific "condition" variables, such as experimental batches or sensitive attributes. By enforcing this independence, CoMP achieves state-of-the-art results in biological data integration, fairness, and—most impressively—counterfactual inference, such as predicting how a specific cell would respond to a drug it was never treated with.

The Challenge of Conditional Independence

In fields like computational biology, researchers often face the "batch effect" problem: data collected from different labs or using different technologies show spurious shifts that mask the real biological signal. To compare these datasets, we need to "integrate" them into a shared space where the technical noise is removed.

A similar challenge exists in fairness (ensuring a model doesn't use protected attributes like gender) and counterfactual inference (predicting "what if" scenarios). The mathematical core of all three problems is identical: we want to learn a representation $z$ of our data $x$ that is marginally independent of a condition variable $c$ ($z \perp \perp c$).

Existing methods, like Variational Autoencoders (VAEs) with Maximum Mean Discrepancy (MMD) penalties, often require tedious hyperparameter tuning and struggle to align complex, multi-clustered data distributions.

The CoMP Approach

CoMP builds on the Conditional VAE (CVAE) framework but introduces a clever new training penalty. Instead of using an external distance measure like MMD, CoMP uses the model’s own variational posteriors to estimate the marginal distributions of different conditions.

The "Contrastive" part of the name comes from its two-pronged objective:

  1. Alignment: It encourages representations from one condition to move toward regions of high density in other conditions.
  2. Entropy Promotion: It prevents the latent space from collapsing into a single point by ensuring representations within the same condition remain spread out.

The authors prove that this penalty is a stochastic upper bound on a weighted sum of Kullback–Leibler (KL) divergences. Furthermore, they provide a theoretical bridge to Independent Component Analysis (ICA), proving that if the latent distribution is non-Gaussian, the model can uniquely identify counterfactuals even from unpaired data.

Key Insights

  • Self-Normalizing Gradients: Unlike MMD, which has "vanishing gradients" for points that are far apart in latent space, CoMP’s gradients are self-normalizing. This allows it to effectively pull together distant clusters that other methods might leave unaligned.
  • Non-Gaussianity is a Strength: While standard VAEs assume Gaussian latents, CoMP thrives on non-Gaussianity. The authors show that non-Gaussian latent structures are actually what make counterfactuals "identifiable" (mathematically unique and discoverable).
  • Unifying Three Domains: The paper elegantly demonstrates that data integration, causal inference, and fair representation learning are essentially the same mathematical task viewed through different lenses.
Visual comparison of latent spaces showing CoMP achieving near-perfect overlap of conditions compared to standard VAE or trVAE.

Experimental Results

The authors evaluated CoMP across four diverse tasks, including aligning bulk gene expression from human tumours with lab-grown cancer cell lines, integrating scRNA-seq data, and a standard fairness benchmark (UCI Adult Income).

CoMP consistently outperformed strong baselines like trVAE and Seurat:

  • Biological Alignment: On the Tumour/Cell Line task, CoMP achieved a Silhouette score ($s$) of 0.023, significantly lower (indicating better mixing) than trVAE's 0.096, while maintaining high classification accuracy.
  • Counterfactual Accuracy: In predicting cell responses to stimulation, CoMP’s reconstructions were remarkably accurate. CoMP successfully avoids the systematic underestimation of gene expression changes that is common in other models.
Boxplots demonstrating that CoMP avoids the systematic underestimation of gene expression changes common in other models during counterfactual inference.
  • Fairness: On the Adult Income dataset, CoMP reduced gender prediction accuracy to near-random (67.9%) while maintaining competitive income prediction accuracy (80.5%).

Limitations and Future Work

While highly effective, CoMP has a few limitations. The proof for counterfactual identifiability assumes a linear decoder; while experiments show CoMP works excellently with non-linear neural networks, a formal proof for the non-linear case remains an open challenge. Additionally, if two batches have real biological differences (e.g., one batch contains a cell type the other doesn't), CoMP might "over-correct" and force them to overlap. The authors suggest using the penalty weight $\gamma$ as a "knob" to balance alignment versus representation accuracy. Finally, like most contrastive methods, CoMP's performance is sensitive to batch size, as it relies on in-batch samples to estimate marginal distributions.

Summary updated

BibTeX
@inproceedings{foster2022contrastive,
  author = {Adam Foster and Árpi Vezér and Craig A. Glastonbury and Páidí Creed and Samer Abujudeh and Aaron Sim},
  title = {{Contrastive Mixture of Posteriors for Counterfactual Inference, Data Integration and Fairness}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=MZZRqq_KyS},
}
Figure