When a machine learning model denies a loan application, rejects a resume, or flags a medical reading, users naturally ask: What would need to change to get a different outcome?
In machine learning, this is the problem of algorithmic recourse or counterfactual explanations. Traditionally, algorithms find these explanations by taking an individual's data point and looking for the smallest possible modification that pushes it across the model's decision boundary.
However, optimizing purely for mathematical distance creates a fundamental paradox. The shortest path across a decision boundary often leads directly into "empty space"—resulting in suggestions that are statistically improbable, physically impossible, or biologically nonsensical. To solve this, a major research direction focuses on data manifold adherence: ensuring that counterfactual explanations remain grounded within the distribution of real-world data.
The Proximity Paradox
To understand why naive counterfactuals fail, imagine a model evaluating health risks based on age and years of employment. If a 25-year-old user is rejected, an unconstrained optimization algorithm might suggest keeping their income the same but changing their employment history to 30 years. Mathematically, this point flips the model's prediction. Practically, it is impossible.
As Sahil Verma et al. explain in their comprehensive review, Counterfactual Explanations and Algorithmic Recourses for Machine Learning: A Review, minimizing standard distance metrics ($L_1$ or $L_2$) frequently produces counterfactual examples that fail to represent feasible human states. Kentaro Kanamori et al. formalize this in DACE: Distribution-Aware Counterfactual Explanation by Mixed-Integer Linear Optimization, highlighting a fundamental tension: prioritizing minimal mathematical distance ignores the underlying structure of the data, violating the statistical properties of the real world.
When explanations ignore these properties, they generate what Susanne Dandl et al. describe as implausible feature combinations in CountARFactuals - Generating Plausible Model-Agnostic Counterfactual Explanations with Adversarial Random Forests. In high-stakes domains, this lack of realism destroys user trust. For instance, in Explaining a machine learning decision to physicians via counterfactuals, Supriya Nagesh et al. point out that automated medical explanations frequently generate out-of-distribution scenarios with impossible vital sign combinations, rendering them useless to clinicians. Similarly, in computer vision, Saeed Khorram et al. observe in Cycle-Consistent Counterfactuals by Latent Transformations that naive pixel tweaks produce unrealistic, ghostly artifacts rather than natural images.
The Geometry of the Data Manifold
Real-world data does not scatter uniformly across a high-dimensional feature space. Instead, it concentrates on a lower-dimensional surface embedded within that space: the data manifold.
Off-Manifold Counterfactual (Unrealistic)
\
\ x (Flipped Prediction)
\
------------------\------------------------- Decision Boundary
\
o (Original Instance)
/
/
x (Manifold-Constrained Counterfactual)
/
~~~~~~~~~~~~~/~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Data Manifold (Realistic Data)
To generate plausible recourse, an algorithm cannot simply jump in a straight line across the decision boundary. It must traverse along the data manifold to find a region where real data points actually exist. Raha Moraffah et al. emphasize in Causal Interpretability for Machine Learning - Problems, Methods and Evaluation that maintaining this manifold closeness is essential for the plausibility of any generated "what-if" scenario.
Researchers have converged on three primary strategies to force counterfactuals to adhere to this manifold: instance-based anchoring, generative modeling, and explicit density constraints.
Strategy 1: Instance-Based Anchoring
The most intuitive way to ensure a counterfactual is realistic is to guide the search using actual data points from the training set. If a target state has already been observed in the real world, it is guaranteed to be physically possible.
- Neighbor Templates: In Instance-Based Counterfactual Explanations for Time Series Classification, Eoin Delaney et al. introduce a method that adapts existing "neighbor" instances from the training data rather than synthesizing points from scratch. This constrains the search space to realistic data patterns.
- Positive Instance Guidance: In Simple Steps to Success: A Method for Step-Based Counterfactual Explanations, Jenny Hamer et al. derive recourse directions directly from existing positive instances in the dataset, preventing the generation of impossible feature combinations in empty regions of the feature space.
- Prototype Interpolation: Similarly, Duy Nguyen et al. show in Feasible Recourse Plan via Diverse Interpolation that selecting successful historical prototypes and interpolating toward them along the data manifold guarantees that the recommended path consists of realistic, achievable states.
Strategy 2: Navigating Latent Manifolds via Generative Models
For high-dimensional data like images, graphs, or complex tabular records, finding exact historical neighbors is insufficient. Instead, researchers use generative models—such as Variational Autoencoders (VAEs), Generative Adversarial Networks (GANs), and Normalizing Flows—to learn a continuous mathematical representation of the data manifold.
As surveyed by Daniil Kirilenko et al. in Generative Models for Counterfactual Explanations, these generative architectures improve explanation quality by constraining the search to a learned latent space. Optimization happens within this low-dimensional latent space, and the generator decodes the result back into a realistic data point.
- Adversarial Discriminators: In CounteRGAN: Generating counterfactuals for real-time recourse and interpretability using residual GANs, Daniel Nemirovsky et al. incorporate a discriminator directly into the counterfactual generation loop. The discriminator acts as a gatekeeper, penalizing any adversarial tweaks that deviate from the natural data distribution.
- Density Mapping: To avoid the stochastic instabilities of VAEs, Tri Dung Duong et al. introduce CeFlow: A Robust and Efficient Counterfactual Explanation Framework for Tabular Data using Normalizing Flows. Normalizing Flows explicitly calculate probability density, allowing the algorithm to actively steer clear of low-density regions.
- Latent Interpolation: In Synthesising Counterfactual Explanations via Label-Conditional Gaussian Mixture Variational Autoencoders, Junqi Jiang et al. structure the latent space using a Gaussian Mixture Model. Recourse paths are generated by smoothly interpolating between the user's representation and learned prototypical centroids of the target class.
- Graph Structures: This paradigm extends beyond continuous spaces; Jing Ma et al. demonstrate in CLEAR: Generative Counterfactual Explanations on Graphs how Graph VAEs can be used to generate counterfactual graph perturbations that respect underlying structural realism.
Strategy 3: Explicit Density and Distance Constraints
A third approach modifies the optimization objective directly, adding mathematical penalties that measure how far a point has drifted from the data distribution.
Instead of relying on standard Euclidean distance, Yukai Zhang et al. propose in Enhancing Counterfactual Image Generation Using Mahalanobis Distance with Distribution Preferences in Feature Space using a specialized Mahalanobis distance within the model's internal feature space. This ensures that the generated counterfactual respects class-specific statistical boundaries.
Alternatively, density estimation metrics can be converted directly into optimization constraints. In Manifold-Aligned Counterfactual Explanations for Neural Networks, Asterios Tsiourvas et al. reformulate the Local Outlier Factor (LOF)—a classic density-based outlier detection metric—into a set of linear constraints. By leveraging the piecewise-linear geometry of ReLU networks, the authors prune the search space to guarantee that explanations never land in low-density outlier regions.
Why Manifold Adherence Matters for Robustness
Enforcing data manifold adherence is not just about making explanations look believable to humans; it is also a prerequisite for mathematical stability and robustness.
Standard "closest" counterfactuals are notoriously unstable. In Evaluating Robustness of Counterfactual Explanations, André Artelt et al. demonstrate that minor perturbations to the input or the model can cause standard counterfactuals to invalidate completely. By forcing counterfactuals to adhere to the data manifold, the explanations become significantly more robust. This stability is critical when models evolve over time; André Artelt et al. note in Contrastive Explanations for Explaining Model Adaptations that explaining model shifts due to concept drift requires contrastive explanations that remain strictly within the actual data manifold to avoid adversarial artifacts.
Furthermore, true recourse requires what Julia El Zini et al. term manifold connectedness in Beyond Model Interpretability: On the Faithfulness and Adversarial Robustness of Contrastive Textual Explanations. An explanation should not represent a disjointed jump to a distant, isolated pocket of the feature space; it must provide a smooth, continuous path of logical transitions from the original input to the target state.
Recent work shows that this constraint can be maintained even under complex deployment conditions:
- Model Multiplicity: When multiple different models achieve identical accuracy but draw different internal boundaries, Vineet Rajani et al. show in Counterfactual Explanations and Model Multiplicity: a Relational Verification View that formal optimization can find explanations that are simultaneously valid across an entire ensemble of models while strictly maintaining adherence to the underlying data manifold.
- Adversarial Training: While robust models are typically harder to provide recourse for, Yang Liu et al. demonstrate in Adaptive Adversarial Training Does Not Increase Recourse Costs that adaptive adversarial training preserves low recourse costs while keeping suggestions faithful to the data distribution.
Ensuring that explanations remain on the data manifold bridges the gap between pure mathematical optimization and real-world feasibility. Whether through instance-based anchoring, generative latent spaces, or explicit density constraints, constraining explanations to the data manifold changes algorithmic recourse from an abstract mathematical exercise into a practical, trustworthy tool for human decision-making.
Key Foundational Work
Counterfactual Explanations and Algorithmic Recourses for Machine Learning: A Review (2020) — contributed 3 concept elements to this direction.
Evaluating Robustness of Counterfactual Explanations (2021) — contributed 1 concept elements to this direction.
Instance-Based Counterfactual Explanations for Time Series Classification (2021) — contributed 1 concept elements to this direction.