Abstract
The increasing use of machine learning algorithms in social applications has raised concerns about fairness and transparency, leading to the development of counterfactual explanations. These explanations support individuals to understand and potentially alter unfavorable decisions in areas such as loan applications, job selections, and more, by providing actionable changes to input features that would lead to a desired outcome. Existing methods often struggle to balance feasibility, plausibility, and computational efficiency. To address this, we introduce P\(^{2}\)CE, an algorithm for generating plausible Pareto-optimal counterfactual explanations, offering users a diverse set of optimal trade-offs between different notions of feasibility. P\(^{2}\)CE employs an auxiliary isolation forest outlier detector to ensure that explanations are in accordance with the data distribution and leverages SHAP values to obtain optimal results with short computing times, regardless of the underlying model. Our algorithm was empirically evaluated on three datasets, demonstrating superior performance in terms of both solution quality and computational efficiency compared to related techniques.
1 Introduction
Machine learning algorithms are now present daily in the lives of individuals, making many small, hidden decisions. However, these algorithms are also being used for decisions with a high impact on individuals, such as credit scoring, selection processes, health diagnosis, and others. In these contexts, supporting individuals in obtaining the desired prediction is important: “My request was denied; what should I do next to have an accepted loan?”. Furthermore, regulations in diverse countries already ask for explanations on predictions, such as the EU General Data Protection Regulation (GDPR). Counterfactual explanations were proposed to answer such concerns (Wachter et al., 2017), defined as changes in feature values necessary to obtain the desired prediction. The main objective of such explanations is to be truthful for the model’s decision-making and to be actionable (Karimi et al., 2021). Counterfactual explanations should be feasible—suggested changes are achievable by the particular individual—and should be plausible—they are probable observations within the data distribution.
Given an observation x, counterfactual explanations can be expressed as a vector \(x+a\) where a represents the changes suggested for each feature. Previous works have been developed in this context, and different methods for measuring the feasibility of suggested changes a have been discussed (Verma et al., 2024). First, suggested changes should be small, as larger changes in features cannot be reachable for an individual (suggesting a tenfold increase in income is not a useful counterfactual explanation, for example). Secondly, they should be sparse, suggesting changes in only a subset of features. This is motivated because a larger number of small changes may be worse compared to a moderate change on a smaller number of features. Furthermore, due to the subjective preference of individuals, no single measure of feasibility can be used for all scenarios. By providing multiple diverse solutions, different personal preferences can be supported. Previous works considered working with multiple objectives by defining a weighted loss (Mothilal et al., 2020) or employing multi-objective optimization to obtain a Pareto-optimal set of solutions (Raimundo et al., 2022).
However, when maximizing feasibility, algorithms might present solutions that are not likely to be based on the data distribution. In Fig. 1, we present an example of counterfactual explanations with two features and Euclidean distance as a measure of feasibility. In this example, while the triangular solution might be closer in Euclidean distance to the reference sample (black dot), this solution is not inside the data distribution. The square solution, on the other hand, might be more distant from the reference sample; however, it ensures plausibility. In this simple example, the triangle solution was obtained by MAPOCAM (Raimundo et al., 2022) while the square solution is our algorithm. Previous algorithms have already been presented to ensure the plausibility of counterfactual explanations (Kanamori et al., 2021; Poyiadzi et al., 2020). However, they did not consider the importance of optimality regarding the multiple objectives.
Counterfactual explanation algorithms are also heavily dependent on the model considered. Depending on the complexity of the model, optimal counterfactual explanations might be challenging to obtain. Initial works presented solutions for differentiable and linear models, with more recent approaches being model-agnostic, considering that the model is a black box where only the predictions are known. Although these proposals may not achieve optimal efficiency across all models in computing cost, they are easily integrated into real-world applications.
We present P\(^{2}\)CE, an algorithm designed to generate Plausible Pareto-optimal Counterfactual Explanations. P\(^{2}\)CE draws upon the previous work, MAPOCAM, but further improves the algorithm to ensure the plausibility of counterfactual explanations. The algorithm also addresses the limitations of prior research by enabling the generation of counterfactual explanations applicable to any model. Our proposal is based on a branch-and-bound search in a grid of possible counterfactual explanations. Still, it leverages outlier detection and SHAP values to avoid searching regions without useful solutions. This procedure can be done considering multiple objectives that commonly arise in the context of counterfactual explanations. P\(^{2}\)CE obtains Pareto-optimal solutions; thus, no other solution in the space of counterfactual explanations would have costs lower than or equal to those of P\(^{2}\)CE in all of the objectives. In summary, our contributions are as follows:
-
P\(^{2}\)CE: A novel algorithm model-agnostic for the generation of optimal counterfactual explanations under multi-objectives that ensures that explanations are within the data distribution.
-
The exploration of a SHAP’s property that allows us to foresee if a set of variables can achieve a counterfactual. Thus expanding the agnostic capability of counterfactual explanations.
-
An extensive evaluation of the proposed algorithm with multiple datasets and classifiers, compared with related techniques. The evaluation considers multi-objective values, computing time, and outlierness of solutions.
-
An open-source implementation of P\(^{2}\)CE: https://github.com/hiaac-finance/p2ce
2 Background and Related Works
We now formalize the problem of generating counterfactual explanations and present relevant works on the topic. In this section and in the remainder of this paper, we consider that we have access to a dataset \(D = (X, Y); X \in \mathbb {R}^{n\times d}; Y \in \{0, 1\}^n\) sampled from a distribution P. We note as (\(x_i, y_i\)) the i-th sample of D and x(i) as the i-th coordinate of vector x. We also have a fitted classifier \(f: \mathbb {R}^d \rightarrow [0, 1]\) that approximates the probability \(f(x) \approx P(Y = 1 \mid X = x)\). The classifier is accompanied by a threshold \(\tau \in [0, 1]\), and a positive decision \(\hat{y}_i = 1\) is made when \(f(x_i) \ge \tau\).
2.1 Explanations
Explainability has emerged as a very relevant area of research in machine learning as complex models become widely employed in applications that greatly impact individuals’ lives. “Explanations” are presented in different forms, but, in general, they try to answer the question “which features of the input were determinants of the output of the model?”. These explanations can be “global”, with a general description of the relevant features for any input (Friedman, 2001; Goldstein et al., 2015), or “local” where for a specific observation x, it is desired to obtain the set of relevant features. LIME (Ribeiro et al., 2016) and SHAP (Lundberg and Lee, 2017) are among the most widely used methods for local explanations and present a similar concept: studying how small perturbations in each feature impact the model prediction. For a given observation x and a model f, a vector \(\phi \in \mathbb {R}^d\) is returned where \(\phi (i)\) represents the “importance of the feature i” in this prediction. In particular, SHAP has the property that \(f(x) = \mathbb {E}[f(x)] + \sum _{i=1}^d \phi (i)\), and each \(\phi (i)\) can be seen as the “contribution” of the feature i to the total prediction f(x).
2.2 Counterfactual Explanations
Unlike the general idea of explanations, where the objective is to comprehend the rationale behind complex model predictions, counterfactual explanations are designed to give individuals the possibility of action (Wachter et al., 2017), which are also commonly called actionable recourse (Ustun et al., 2019; Karimi et al., 2021). Molnar (2018) elucidates that counterfactual explanations are an accessible method to illustrate “what-if” scenarios: “What would be the prediction of the model for credit scoring, given that I increased my annual income by 10%?”. These “what-if” scenarios should consider the closest world possible, as considering absurd scenarios would not contain relevant information about the model and would not be an actionable explanation. Wachter et al. (2017) formalized the problem of generating counterfactual explanations as follows:
This formulation searches for a value \(x'\) with a prediction \(f(x')\) equal to the desired outcome \(y'\). The function c is a measure of the distance between x and \(x'\) and encapsulates the idea of “closest world”. This distance function c should be able to represent the ease of reaching \(x'\) from x in the real world, i.e., if \(x'\) is a feasible scenario for an individual with attributes x.
2.3 Related Works
Previous works have pointed out important aspects for high-quality counterfactuals. Algorithms must ensure feasibility (Mothilal et al., 2020; Raimundo et al., 2022; Verma et al., 2024; Guidotti, 2024), so that suggested changes are reachable by individuals. Another concern is that solutions should be plausible, i.e., the suggested profile \(x'\) should be probable in real-world data (Kanamori et al., 2021; Poyiadzi et al., 2020). Lastly, to fulfill individual preferences, it is important to provide multiple and sdiverse counterfactual explanations (Mothilal et al., 2020; Russell, 2019). Recent work has also investigated methods for solving similar problems to Eq.1. Some solutions were limited to specific models, such as linear models (Ustun et al., 2019; Russell, 2019), tree ensembles (Dutta et al., 2022; Lucic et al., 2022; Parmentier and Vidal, 2021), image models (Augustin et al., 2022), or differentiable models (Mothilal et al., 2020). Recent work has also considered model-agnostic algorithms, which are advantageous because they are not restricted to certain model classes. Due to the similarity with our work, we discuss model-agnostic methods in more detail.
To ensure generated counterfactuals are plausible and adhere to the data manifold, several methods utilize density information or generative models. For instance, Poyiadzi et al. (2020) and Keane and Smyth (2020) leverage graph-based shortest paths and nearest-neighbor strategies, respectively, to find counterfactuals within the data distribution, while Redelmeier et al. (2024) models the conditional feature distributions. Alternatively, generative models can be used to directly sample valid counterfactuals (Yang et al., 2021) or action vectors (Nemirovsky et al., 2022).
Other approaches frame the generation process as a heuristic search or optimization problem to handle complex objectives. Reinforcement Learning (RL) has been adapted to this setting, where agents are rewarded for getting closer to the desired prediction (Verma et al., 2022; Samoilescu et al., 2021). Genetic algorithms are also widely employed to manage non-differentiable constraints and multi-objective functions (Schleich et al., 2021; Forster et al., 2021), including causal validity (Duong et al., 2024) or sequential action planning (Naumann and Ntoutsi, 2021). Furthermore, some works focus on specific search improvements, such as optimizing directly in feature space (Becker et al., 2021) or accounting for user-specific preference distributions over costs (Yadav et al., 2021).
Despite these advancements, no existing model-agnostic methods have been able to simultaneously ensure plausibility and optimality with respect to all cost functions. While distribution-aware solutions have not considered multiple objectives, other genetic and heuristic-based methods can still generate out-of-distribution counterfactual explanations, which can represent unrealistic actions.
2.4 Pareto-Optimal Counterfactual Explanations
In the classification setting, we are interested in counterfactual explanations \(x' = x + a\) such that \(f(x') \ge \tau\) while \(f(x) < \tau\). The vector a can be called an action and has a useful interpretation: coordinate a(i) represents the increase/decrease necessary on the i-th feature; if \(a(i) = 0\), no change is necessary. Feasibility has been measured in the literature in different ways, which motivates the use of multi-objective distance functions \(C: \mathbb {R}^d \times \mathbb {R}^d: \mathbb {R}^m\), where we have m objectives, each one being a distance function \(c: \mathbb {R}^d \times \mathbb {R}^d \rightarrow \mathbb {R}\). Considering that \(\mathcal {N}\) is the set of indices of numerical features, one can calculate the average “length” of the change in the values of the features. We call this metric average continuous distance:
Where r(i) is the standard deviation of the feature i. Similarly, the cost of a counterfactual explanation can be represented by the maximum length of changes. We define the maximum continuous distance as:
When dealing with categorical features, we cannot directly measure the length of a suggested change. To consider such a variable type, an approach in the literature has been to measure the number of suggested changes, that is, the number of features with different values. This metric also arises from the idea of sparsity, which considers that moderate changes in a small number of features might be more feasible than small changes in a very large number of features. This can be calculated among all the features, not only the numerical ones. We call it as number of changes distance:
When dealing with multi-objectives, the preference among two solutions w and z must consider all of the objectives. A solution can be seen as non-dominated if there is no other solution that is better in all objectives. These solutions can be multiple, and we can call them Pareto-Optimal solutions.
Definition 1
(Pareto-Optimal Solutions) Given a multi-objective function \(C(x, \cdot ):\) \(\mathbb {R}^d \rightarrow \mathbb {R}^m\) that we want to minimize and a set of solutions \(\mathcal {A}\), a solution w is Pareto-optimal if and only if \(\not \exists z \in \mathcal {A}\) such that \(C(x, z) \preceq C(x, w)\), i.e., \(c_i(x, z) \le c_i(x, w), \forall i\).
The problem of generating counterfactual explanations with multiple objectives has previously been considered by Raimundo et al. (2022) with MAPOCAM. This algorithm uses a branch-and-bound strategy to find the Pareto-Optimal solutions in a large set \(\overline{\mathcal {A}}\) of possible counterfactual explanations. \(\overline{\mathcal {A}}\) is built for each sample x as the product of discretized grids for each feature \(\overline{\mathcal {A}}(i)\), i.e., \(\overline{\mathcal {A}} = \overline{\mathcal {A}}(1) \times \dots \times \overline{\mathcal {A}}(d)\). If the discretization of each feature has 10 different values, verifying which possibilities are valid counterfactual explanations would have complexity \(O(10^d\delta )\) where \(\delta\) is the cost of calling f(x). This complexity may be infeasible even with a few features, and MAPOCAM employs different pruning strategies to reduce computational complexity.
MAPOCAM is presented in Algorithm 1. It searches for actions a that present at most k suggested changes such that \(f(x+a) \ge \tau\). Starting with \(a = {\varvec{0}}\), it constructs counterfactual explanations by considering changing a feature at a time. This procedure can be performed efficiently since commonly defined costs for counterfactual explanations, such as the three presented above, have monotonicity with respect to |a|. In more detail, we say that \(c_i\) is monotonic if \(a, a' \in \mathbb {R}^d\) satisfy \(|a(i)| \le |a'(i)| \; \forall i \in \{1, \dots , d\}\) (\(|a'|\) is component-wise bigger than |a|, write \(|a| \preceq |a'|\)), then \(c_i(x, x+a) \le c_i(x, x+a')\). When C is composed of cost functions that are individually monotonic, we have that if \(|a| \preceq |a'|\) then \(C(x, x+a) \preceq C(x, x+a')\). The search strategy is designed so that if \(|a| \preceq |a'|\), the action \(a'\) will only be evaluated after a has been evaluated. The resulting property is that the distances will not reduce as the search goes deeper. Based on that, each \(\overline{A}(i)\) is ordered based on the absolute values.
Another strategy to reduce complexity is to stop the search based on a bound of the maximum prediction \(f(\cdot )\) that the current node can reach. Consider that the features \(\mathcal {D} = \{1, \dots , j\}\) have already been evaluated in the search, and the following path will only evaluate by altering the features \(\{j+1, \dots , d\}\). We are interested in:
Suppose we know that \(\overline{f}_a < \tau\), following this path will not result in valid counterfactual explanations. To calculate this bound, MAPOCAM uses the property that some classifiers have monotonicity with respect to input x. If f is monotonic with respect to each coordinate of x, the maximum value can easily be obtained by considering the action that has \(a'(i) = a(i); \forall i \in \mathcal {D}\), and for \(i \notin D\), \(a'(i) = \max \overline{\mathcal {A}}(i)\) if f is an increasing function of the i-th coordinate or \(a'(i) = \min \overline{\mathcal {A}}(i)\) if it is a decreasing one. MAPOCAM is also capable of calculating the exact value of \(\overline{f}_a\) with tree ensembles. In this scenario, the trees are traversed following the values of \(x+a\), and when a split is decided by a feature not in \(\mathcal {D}\), it should return the maximum output of following both paths.
Although MAPOCAM is capable of obtaining Pareto-optimal counterfactual explanations that are feasible, it may fail when considering plausibility. Certain solutions may not have a significant probability of being observed in the real world. Furthermore, the bound strategy depends on the fact that f has monotonicity with respect to x, which is not valid for models such as SVM and neural networks. Our proposal, P\(^{2}\)CE, improves the previous work by altering the algorithm so that we generate counterfactual explanations that are inlier (Sect. 3) and supporting any model, without the monotonicity constraint (Sect. 4).
3 Generating Inlier Counterfactual Explanations
Although many proposed algorithms focus on generating feasible counterfactual explanations, they may fail to ensure plausibility. This is also the case for MAPOCAM. Even if a counterfactual explanation is feasible and has a great proximity to the reference sample, it can still be outside the data distribution, as illustrated by the simple example in Fig. 1. Our proposed algorithm, P\(^{2}\)CE, was designed to generate Pareto-optimal inlier counterfactual explanations using the isolation forest (Liu et al., 2008) algorithm for outlier detection.
For a dataset \(X \sim P\), an outlier detection function \(u(x) = 1\) if \(P(X = x) \le \varepsilon\), where \(\varepsilon\) is a small positive value, and \(u(x) = 0\) otherwise. The isolation forest algorithm learns the function u by creating multiple decision trees that are optimized to minimize the number of samples in each leaf. Samples that are “outside” the data distribution will be more easily isolated, and therefore the path from the root to the respective leaf will be shorter. One useful property of an isolation forest is that, because it is a tree ensemble, it is capable of producing predictions when some coordinates of the input are absent. This is achieved by exploring both potential paths when the decision variable at a node is indeterminate. While this could be done with other models by replacing the average value at the missing variables, trees present advantages as each split uses only one feature, which could result in the missing variable not being used at multiple nodes. Furthermore, isolation forest has presented the best results in outlier detection tasks in recent benchmarks (Bouman et al., 2024).
MAPOCAM searches for counterfactual explanations in a grid \(\overline{\mathcal {A}}\) that is defined based on the product of discretized feature values. However, a counterfactual explanation \(x+a\) may be feasible but outside of the data distribution, as \(\overline{\mathcal {A}}\) is created without considering the correlation between the features. In that sense, such a counterfactual explanation may not be useful to an individual, as the point \(x+a\) is not reachable. Our objective is then to collect all Pareto-Optimal solutions in the set of inlier counterfactual explanations. It is important to note that this procedure will result in a different set of solutions than obtaining all Pareto-optimal actions and removing the ones from this set that are outliers.
P\(^{2}\)CE is presented in Algorithm 2. Whenever a valid solution \(x+a\) is found in the search, P\(^{2}\)CE verifies whether this counterfactual explanation is an outlier. If not, we can add this solution to the set S. Otherwise, this solution should not be included in the set of solutions. Although the cost of the counterfactual explanation will only increase when considering further changes in coordinate i, larger changes can return to being within the data distribution. This procedure could be performed with an arbitrary outlier detection u, such as isolation forest, autoencoder-based approaches, or local outlier factor.
An additional gain in efficiency can be obtained if u can evaluate whether samples \(\tilde{x}\) with missing values are outliers. \(u(\tilde{x}) = 1\) indicates that placing any value in the undefined coordinates will also result in an out-of-distribution sample. In that way, there is no need to consider further changes in these coordinates. This procedure is performed by P\(^{2}\)CE on lines (20–21).
4 Estimating Maximum Prediction for Any Model
As presented in Alg. 2, the branch-and-bound strategy used by P\(^{2}\)CE depends on the estimation of \(\overline{f}_a\), the maximum prediction obtainable by further changes in action a. If this value is lower than \(\tau\), traversing this branch becomes unnecessary. In MAPOCAM, this estimate is done under the assumption of model monotonicity, as discussed in Sect. 2. Widely used models, including KNN, neural networks, SVM, and others, do not adhere to this assumption. We present a method for estimating the maximum prediction based on SHAP values (Lundberg and Lee, 2017) using the additive property of feature attributions.
In more detail, we have a partial solution \(x+a\) with a set of features \(\mathcal {D}\) that will not have their values altered (either they were fixed by the user, or they are fixed because their values have already been altered previously in the search process). Let \(\mathcal {X}_{(a, \mathcal {D})}\) denote the space where all elements have the same fixed values as x, i.e., if \(\tilde{a} \in \mathcal {X}_{(a, \mathcal {D})} \implies a(i) = \tilde{a}(i), \forall i \in \mathcal {D}\). The goal is to determine \(\overline{f}_a:= \max _{\tilde{a} \in \mathcal {X}_{(a, \mathcal {D})}} f(x + \tilde{a})\). If \(\overline{f}_a < \tau\), there is no valid counterfactual in \(\mathcal {X}_{(a, \mathcal {D})}\).
SHAP values have the property of being additive feature attributions, that is, \(f(x) = \mathbb {E}[f(x)] + \sum _{i=1}^d \phi _i(x)\), where \(\phi _i(x)\) represents the attribution of the i-th feature calculated for sample x. Notice that \(\sum _{i \in \mathcal {D}} \phi _i(x)\) reflects the attribution of fixed features, while \(\sum _{i \notin \mathcal {D}} \phi _i(x)\) relates to open ones. Consider that \(\overline{\phi }_{p}\) is the maximum attribution of the feature p for any value of x in the domain of \(\mathcal {X}\). Although we may not have access to the support of \(\mathcal {X}\), we can approximate \(\overline{\phi }_p\) by calculating the feature attributions of a large dataset and calculating the maximum value. Thus, we obtain a bound for \(\overline{f}_a\):
where \(x^\star\) solves the maximization problem, \(\phi _i(x)\) and \(\phi _i(x^\star )\) are the SHAP values for the i-th feature for the solutions x and \(x^\star\) respectively. Notice that this upper bound has a residual term \(R_{(x, \mathcal {D})}\) that is the difference between the attributions of fixed features (from \(\mathcal {D}\)) of the initial observation x and the solution \(x^\star\). Later, we will discuss how the residual \(R(x, \mathcal {D})\) is a small value whenever \(\mathcal {X}_{(a, \mathcal {D})}\) is small.
As we are using an upper bound on the optimization problem, we overstate the maximum prediction, which could increase the computational time. However, this overestimation does not compromise the quality of the solutions obtained. In Sect. 5, we evaluate the computing cost of our solution in real-world datasets.
We can make a small alteration to the previously formulated problem to reduce the upper bound. This is done by considering that the generation of counterfactuals is usually done with a constraint on how many features will be changed simultaneously. Let k be the number of features that can be further altered from the partial solution \(x + a\) and \(\mathcal {X}_{(a, \mathcal {D}, k)} = \{ \tilde{a} \in \mathcal {X}_{(a, \mathcal {D})} \mid \sum _{i \notin \mathcal {D}} \mathbb {I}[a_i \ne \tilde{a}_i] \le k \}\) that is, the set of actions that have at most k open features different from a. Let \(O_k \subseteq \mathcal {D}^C\) be the set of k open features that have the k-biggest \(\overline{\phi }_i\), i.e., if \(i \in O_k \implies \overline{\phi }_i \ge \overline{\phi }_j \forall j \notin O_k\). Using the same idea as from the previous proof, we can obtain a similar upper bound:
As \(O_k \subseteq D^C\), we have \(\left( - \sum _{i \in O_k}\phi _i(x) + \sum _{i \in O_k} \overline{\phi }_i \right) < \left( - \sum _{i \in \mathcal {D}^C}\phi _i(x) + \sum _{i \in \mathcal {D}^C} \overline{\phi }_i \right)\) and this formulation gives an upper bound that is lower than the previous one obtained. We will estimate that \(\overline{f}_a\) is smaller than \(\tau\) more frequently, thus reducing the number of branches that the algorithm needs to search for.
One last detail is the residual term \(\mathcal {R}\). This term is the difference between the feature attributions of the reference sample x and the point \(x^\star\) that maximizes \(f(x^\star )\) (\(x^\star = x + a', a' \in \mathcal {X}_{(a, \mathcal {D}, k)})\). The lower this value, the tighter our upper bound is going to be. During the search, x and \(x^\star\) will be close values, since only k features are changed at most. Previous work by Khan et al. (2024) has theoretically analyzed explainer “astuteness”: how much explanations can change when the input sample is altered. A function f is probabilistic Lipchitz if for all \(x_1, x_2\) such that \(||x_1-x_2||_ 2 \le r\) (for some constant r), we have with high probability that \(||f(x_1) -f(x_2) ||_2 \le L|| x_1- x_2||_ 2\). In this scenario, Khan et al. showed that the SHAP explanations for \(x_1, x_2\) will satisfy \(||\phi (x_1) - \phi (x_2)||_2 \le L' ||x_1- x_2||_2\) where \(L'\) is a constant that increases with L, that is, close samples \(x, x^\star\) will have close explanations. In our case, we interested when \(x, x^\star \in \mathcal {X}_{(a, \mathcal {D}, k)}\), inducing the constraint \(||x-x^\star ||_2 \le r\). Furthermore, trees’ ensembles and neural networks will be probabilistic Lipchitz when trained with stronger regularization, resulting in more stable explanations. This result indicates that \(R_{(x, \mathcal {D})}\) will be small when \(\mathcal {X}_{(a, \mathcal {D}, k)}\) is small.
5 Experiments
To evaluate the proposed algorithm and compare it against related techniques, we performed a set of experiments using common classifiers and real-world benchmark datasets. Our experiments evaluated the capabilities of P\(^{2}\)CE in generating solutions that are inside data distribution and are optimal with regard to multiple objectives.
Datasets We considered five benchmark datasets of different numbers of samples and features. German Credit (Hofmann, 1994) contains 1000 samples with 27 client features and a classification as good or bad risk. The Taiwan (Yeh, 2016) dataset includes information on credit card default from 30,000 clients of a Taiwanese bank with 11 features after preprocessing. The HomeCredit (Montoya and KirillOdintsov, 2018) dataset contains 300,00 instances representing borrowers’ historical data and other economic information, with the label being whether the applicant defaulted after 2 years. We selected 50,000 random samples and 60 features. We also considered the Adult dataset (Becker and Kohavi, 1996), a dataset with personal information and income data collected from the US 1994 census with 8 features for 48,000 individuals. The ACS Income (Ding et al., 2021) is obtained from the US Census, as a new dataset designed to replace the Adult dataset. This dataset contains social and professional information about US citizens and whether their yearly income is more than U$50,000. After preprocessing, this dataset ended with 6 features, and we randomly selected 50,000 samples.
To be able to support MAPOCAM, we removed from the datasets categorical features that are not binary. In each dataset, we selected a set of features that should be considered to generate counterfactual explanations, avoiding immutable personal characteristics. In the end, German Credit had 21 considered features, Taiwan had 10, HomeCredit had 8, Adult had 8, and ACS Income had 4.
Classifiers Our experiments included commonly employed classifier algorithms, which include a Logistic Regression (LR), Gradient-Boosting (LightGBM), and a Multi-Layer Perceptron (MLP). LR satisfies the monotonicity constraints imposed by MAPOCAM and was used in an ablation study of the inlierness of counterfactual explanations. Remaining classifiers are highly complex with non-linearities and highlight the flexibility of P\(^{2}\)CE.
Compared Algorithms Experiments included comparisons with MAPOCAM (Raimundo et al., 2022) to demonstrate the improvements obtained from our novel algorithm. A comparison was also made with DICE (Mothilal et al., 2020) and NICE (Brughmans et al., 2024), two popular algorithms for counterfactual explanations. DICE was initially presented as a gradient-based algorithm to generate diverse solutions; however, we employ a genetic implementation with the same objective, but it is model-agnostic. It can generate an arbitrary number of counterfactual explanations and tries to maximize diversity among them. To avoid DICE generating outlier counterfactual explanations, we adjust the permitted range of each continuous feature to be within the 98% distribution interval. NICE is a fast approach that uses information from neighboring samples to generate counterfactual explanations. It is limited to generating only one solution for the input sample.
Setting The datasets were separated into train, validation, and test sets of size 40%, 10%, and 50%. Hyperparameter tuning was performed with the Optuna package (Akiba et al., 2019) with 50 trials, and the final models are those that achieved the highest balanced accuracy in the validation set. P\(^{2}\)CE used an isolation forest fitted to the training data. A stronger algorithm, the extended isolation forest (Hariri et al., 2019), was fitted on the test data to evaluate the plausibility of counterfactual explanations. To classify outliers, we consider that all datasets have a contamination rate of 5% of outlier samples. The metrics reported in the following are the average result of generating counterfactuals for 500 randomly selected individuals from the test set that obtained the negative prediction (we used a smaller number of selected individuals from the German dataset due to its size).
5.1 Inlierness of Counterfactual Explanations
The initial experiment is intended to demonstrate the ability of P\(^{2}\)CE in generating plausible counterfactual explanations compared to MAPOCAM. To do so, we generated counterfactual explanations for the LR model, which satisfy monotonicity with respect to input x. In that way, P\(^{2}\)CE does not need to use SHAP to estimate \(\overline{f}_a\), and the difference between algorithms is only how they deal with outlier solutions. We also performed an ablation study by removing the procedure from lines 20–21 of Alg. 2 that evaluates if partial solutions can already be classified as outliers. We call this simplified version P\(^{2}\)CE (Ablation). Both algorithms were executed considering solutions with at most 3 changes and considering only one objective, the average continuous distance.
The results for three datasets are depicted in Table 1, including the average computation time, the average distance of the solutions, and the percentage of solutions that were outliers due to only using one objective. The set of Pareto-Optimal solutions is composed of only one solution. While the number of outlier counterfactual explanations is similar among the three methods on the German and Taiwan dataset, on the Adult dataset, MAPOCAM outputted 22% of outlier solutions, while P\(^{2}\)CE (Ablation) resulted only in 6%, and P\(^{2}\)CE resulted only in 3%. P\(^{2}\)CE had a higher cost than MAPOCAM; this is expected. By removing solutions from \(\overline{\mathcal {A}}\) (due to them being outliers), one might remove solutions that would be Pareto-Optimal. This also increases the number of solutions that must be evaluated before finding a valid one. When comparing P\(^{2}\)CE and P\(^{2}\)CE (Ablation), the average computing time shows that the procedure of evaluating if partial solutions are already outliers can help the algorithm in avoiding unnecessary search. For example, P\(^{2}\)CE (Ablation) took on average 38 s on the Taiwan dataset, while P\(^{2}\)CE took only 14 s, being even faster than MAPOCAM.
5.2 One Objective in Non-linear Classifiers
Using an LGBM and an MLP, we evaluated P\(^{2}\)CE, MAPOCAM, DICE, and NICE capabilities of generating a counterfactual with small cost. P\(^{2}\)CE and MAPOCAM were configured with the average continuous distance objective and considering actions that change at most three features. P\(^{2}\)CE is using the Tree Explainer for the LGBM model and the Deep Explainer for the MLP model. MAPOCAM uses the adapted version for tree ensembles in the experiments with LGBM. DICE is set to generate only one solution. We present the results in Fig. 2 for the LGBM classifier and Fig. 3 for the MLP classifier.
In all scenarios, P\(^{2}\)CE achieved the lowest cost while maintaining highly competitive computational time. The difference in computing time between MAPOCAM and P\(^{2}\)CE is more evident in the MLP experiments. MAPOCAM did not use an estimate of \(\overline{f}_a\) and had to evaluate many possibilities from \(\overline{\mathcal {A}}\), taking 20 s on average in the German and Taiwan dataset, and 50 s for the HomeCredit dataset. P\(^{2}\)CE was able to obtain the solutions in a few seconds. In the LGBM experiment, while MAPOCAM uses the tree structure to estimate the maximum prediction of the model, the cost of this procedure is higher than the approach used by P\(^{2}\)CE in the first three datasets. Interestingly, in Adult and ACSIncome, MAPOCAM was slightly faster than P\(^{2}\)CE. The results show that DICE and NICE algorithms are faster than P\(^{2}\)CE, yet they do not have the guarantees of generating Pareto-optimal solutions. Furthermore, NICE cannot handle multiple objectives or generate more than one counterfactual.
The bar plots at the bottom of Figs. 2 and 3 show the percentage of outlier solutions generated by each algorithm. In all cases, P\(^{2}\)CE has the smallest outlier rate, and lower than 5% in almost all datasets. The only compared algorithm with competitive results was MAPOCAM. However, P\(^{2}\)CE significantly exceeded the results from MAPOCAM with the MLP model. DICE, even with the limitation in the range of counterfactual explanations, resulted in very high outlier rates.
5.3 Multiple-objective
To evaluate our proposal considering multiple objectives, we execute P\(^{2}\)CE using the three objectives present in Sect. 2: average continuous distance, maximum continuous distance, and number of changes. MAPOCAM was executed using the same objectives, DICE was executed to generate 4 counterfactual explanations for each individual, and NICE was not included in this experiment, as its formulation does not consider multiple objectives.
Comparing solutions with multiple objectives is not a straightforward procedure. To do so, we utilize hypervolumes, a metric defined as the ‘volume” defined between the Pareto frontier (region of Pareto-optimal solutions) and the worst performance identified. Let \(\{c(x, x_1), \dots , c(x, x_r)\}\) be the set of m-dimensional costs (\(c(x, x') \in \mathbb {R}^m\)) calculated from the r Pareto-optimal solutions \(\{x_1, \dots , x_r\}\) found by an algorithm. We normalize costs by the maximum value (among all algorithms and individuals) so that \(c(x, x') \in [0, 1]^m\) and use \({\varvec{1}}^m\) as the reference point to calculate the volume. Fig. 4 illustrates this with an example of 2 objectives. We display the solutions of two methods, colored in blue and orange, and the reference point in (1, 1). The method in orange has the maximum value observed in the cost 1, and in the cost 2, and after normalization, it ended with a value of 1 in both costs. The hypervolume is equal to the filled area in each plot.
Results are displayed in Table 2. We also included the percentage of solutions that were outliers and the average computing time. With all datasets and models, MAPOCAM presented the highest volume, closely followed by P\(^{2}\)CE. This result was expected as MAPOCAM presents guarantees in obtaining Pareto-Optimal solutions. Even though P\(^{2}\)CE also presents such theoretical guarantees, it is not capable of obtaining MAPOCAM solutions, as some of them are outliers, and also due to the SHAP approximation error. However, the low distances of MAPOCAM solutions are accompanied by a high computational cost. For example, MAPOCAM required 100 s to generate counterfactual explanations with the Taiwan dataset and MLP, while P\(^{2}\)CE took less than 1 s. In all data sets and models, DiCE represented really low hypervolume values, which are not competitive with the other two techniques.
As counterfactual explanations are designed to support users in a decision-making process, it is important to present them visually. We present an illustrative example of counterfactual explanations generated by different algorithms and discuss them qualitatively. For a selected individual from the Adult dataset that obtained the negative prediction from the MLP model, Fig.5 presents the counterfactual explanations identified by DICE and Fig. 6 by P\(^{2}\)CE. In this visualization, we display all features, with features that do not take part in a counterfactual explanation with omitted values. An alternative representation of counterfactual explanations is present in Appendix B. In this example, DICE obtained four counterfactual explanations while P\(^{2}\)CE obtained only three. Despite being similar in terms of considered features, DICE suggested changes in the feature “capital_gain” to increase from 0 to values up to 54,000, which might not be reachable by the individual.
When considering the counterfactual explanations presented by P\(^{2}\)CE, all of them included the “capital_gain” feature. The first one, at the same time as a small capital gain, suggested changing the marital status to “married”, despite an invasive suggestion, it helps understand that such a model captured a pattern that married persons usually have a higher income. The second one suggested an increase of 17 hours in the number of hours worked per week and a capital gain of 9,000. The third one suggests an increase of 13 weekly working hours and a capital gain of 10,000. This result is interesting because it shows an example of a trade-off between two features. It is given to the individual a choice to further increase the weekly working hours or further increase the capital gain, so that the prediction is altered to a positive one. Worth mentioning that P\(^{2}\)CE proposes changes that are more attainable than DICE with smaller increases in capital gain.
6 Limitations and Future Work
P\(^{2}\)CE is capable of generating multiple Pareto-optimal counterfactual explanations for any model. Furthermore, the solutions are obtained with practical computing time. In this section, we discuss some of the limitations of our proposal and present future directions.
SHAP Dependency Our algorithm uses Shapley values to obtain an upper bound of the prediction of a model, as presented in Sect. 4. Shapley values have exponential computing time in the number of variables of the model, and the current literature provides algorithms to approximate such values. This is valid for SHAP algorithms such as Kernel Explainer, Permutation Explainer (Lundberg and Lee, 2017) or DeepLift (Lundberg and Lee, 2017; Shrikumar et al., 2017). Tree Explainer (Lundberg et al., 2018) is an exception, which leverages the tree structure to account for feature interactions. Furthermore, certain models and SHAP implementations may have a higher computing cost than others. The approximation error and computing time from SHAP algorithms should be considered, as P\(^{2}\)CE is dependent on them. The approximation error might mislead the pruning strategy; however, our solutions presented really lower costs than algorithms such as NICE and DICE, and have only higher costs than MAPOCAM, which is guaranteed to obtain Pareto-optimal solutions. Furthermore, research is still being done to obtain exact and efficient SHAP values, which we believe will further improve the capabilities of P\(^{2}\)CE.
Discretized Grid P\(^{2}\)CE searches for counterfactual explanations within a discrete grid of possibilities, and the granularity of this grid limits how close a solution can be identified. Although increasing granularity will result in better optimal solutions, it will also increase search duration. Due to the practical use of counterfactual explanations, a really thin granularity is not necessary. For example, on a credit loan application, a counterfactual explanation that suggests an increase in income by 1000 is equally as good as one that suggests an increase by 998. P\(^{2}\)CE allows the grid to be set with great control for each application by selecting minimum and maximum values and the specific granularity of each future. A possible future direction is developing an adaptive grid, which will automatically increase the granularity of features that can indeed alter the predictions and decrease the granularity of features that have a low impact on the outcome. This procedure could also take advantage of SHAP values to do so.
7 Conclusion
In this work, we presented P\(^{2}\)CE, a novel algorithm for generating Pareto-optimal counterfactual explanations. P\(^{2}\)CE distinguishes itself through its model-agnostic design and distribution awareness, achieved by integrating an isolation forest for outlier detection and leveraging SHAP values for efficient computation. This approach allows P\(^{2}\)CE to provide users with a diverse set of actionable and plausible explanations, even for complex nonlinear models. Our empirical evaluation across various datasets and scenarios demonstrated that P\(^{2}\)CE achieves Pareto-optimal solutions with superior performance in terms of computational cost and outlier detection, enabling faster and more informed decision-making in real-world applications.
Data Availability
Data is provided within the manuscript or supplementary information files.
References
Akiba, T., Sano, S., Yanase, T., Ohta, T., & Koyama, M. (2019). Optuna: A next-generation hyperparameter optimization framework. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. KDD ’19, pp. 2623–2631. Association for Computing Machinery. https://doi.org/10.1145/3292500.3330701 .
Augustin, M., Boreiko, V., Croce, F., & Hein, M. (2022). Diffusion visual counterfactual explanations. Advances in Neural Information Processing Systems, 35, 364–377.
Becker, B., & Kohavi, R. (1996). Adult. UCI Machine Learning Repository. https://doi.org/10.24432/C5XW20
Becker, M. R., Burkart, N., Birnstill, P., & Beyerer, J. (2021). A step towards global counterfactual explanations: Approximating the feature space through hierarchical division and graph search. Advances in Artificial Intelligence and Machine Learning, 1, 90–110.
Bouman, R., Bukhsh, Z., & Heskes, T. (2024). Unsupervised anomaly detection algorithms on real-world data: How many do we need? Journal of Machine Learning Research, 25(105), 1–34.
Brughmans, D., Leyman, P., & Martens, D. (2024). Nice: An algorithm for nearest instance counterfactual explanations. Data mining and knowledge discovery, 38(5), 2665–2703.
Ding, F., Hardt, M., Miller, J., & Schmidt, L. (2021). Retiring adult: New datasets for fair machine learning. Advances in Neural Information Processing Systems, 34, 6478–6490
Duong, T. D., Li, Q., & Xu, G. (2024). Causality-based counterfactual explanation for classification models. Knowledge-Based Systems, 300, 112200.
Dutta, S., Long, J., Mishra, S., Tilli, C., & Magazzeni, D. (2022). Robust counterfactual explanations for tree-based ensembles. International Conference on Machine Learning (pp. 5742–5756) PMLR.
Forster, M., Huhn, P., Klier, M., & Kluge, K. (2021). Capturing users’ reality: A novel approach to generate coherent counterfactual explanations. In Hawaii International Conference on System Sciences. https://api.semanticscholar.org/CorpusID:232412682
Friedman, J.H. (2001). Greedy function approximation: a gradient boosting machine. Annals of statistics, 1189–1232
Goldstein, A., Kapelner, A., Bleich, J., & Pitkin, E. (2015). Peeking inside the black box: Visualizing statistical learning with plots of individual conditional expectation. Journal of Computational and Graphical Statistics, 24(1), 44–65.
Guidotti, R. (2024). Counterfactual explanations and how to find them: Literature review and benchmarking. Data Mining and Knowledge Discovery, 38(5), 2770–2824.
Hariri, S., Kind, M. C., & Brunner, R. J. (2019). Extended isolation forest. IEEE Transactions on Knowledge and Data Engineering, 33(4), 1479–1489.
Hofmann, H. (1994). Statlog (German Credit Data). UCI Machine Learning Repository. https://doi.org/10.24432/C5NC77
Kanamori, K., Takagi, T., Kobayashi, K., & Arimura, H. (2021). Dace: distribution-aware counterfactual explanation by mixed-integer linear optimization. Proceedings of the Twenty-Ninth International Conference on International Joint Conferences on Artificial Intelligence (pp. 2855–2862)
Karimi, A.-H., Schölkopf, B., & Valera, I. (2021). Algorithmic recourse: from counterfactual explanations to interventions. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, pp. 353–362
Keane, M. T., & Smyth, B. (2020). Good counterfactuals and where to find them: A case-based technique for generating counterfactuals for explainable ai (xai). International Conference on Case-Based Reasoning (pp. 163–178). Springer.
Khan, Z. Q., Hill, D., Masoomi, A., Bone, J. T., & Dy, J. (2024). Analyzing explainer robustness via probabilistic lipschitzness of prediction functions. International Conference on Artificial Intelligence and Statistics (pp. 1378–1386) PMLR.
Liu, F. T., Ting, K. M., & Zhou, Z.-H. (2008). Isolation forest. Eighth Ieee International Conference on Data Mining (pp. 413–422). IEEE.
Lucic, A., Oosterhuis, H., Haned, H., & Rijke, M. (2022). Focus: Flexible optimizable counterfactual explanations for tree ensembles. Proceedings of the AAAI Conference on Artificial Intelligence, 36, 5313–5322.
Lundberg, S. M., & Lee, S.-I. (2017). A unified approach to interpreting model predictions. Advances in Neural Information Processing Systems, 30
Lundberg, S. M., Erion, G. G., & Lee, S.-I. (2018). Consistent individualized feature attribution for tree ensembles arXiv:1802.03888 arXiv preprint.
Molnar, C. (2018). A guide for making black box models explainable. URL: https://christophmgithub.io/interpretable-ml-book,3
Montoya, A., & KirillOdintsov, M.K. (2018). Home Credit Default Risk. Kaggle. https://kaggle.com/competitions/home-credit-default-risk
Mothilal, R. K., Sharma, A., & Tan, C. (2020). Explaining machine learning classifiers through diverse counterfactual explanations. Proceedings of the 2020 Conference on Fairness, Accountability, and Transparency (pp. 607–617)
Naumann, P., & Ntoutsi, E. (2021). Consequence-aware sequential counterfactual generation. Joint European Conference on Machine Learning and Knowledge Discovery in Databases (pp. 682–698). Springer.
Nemirovsky, D., Thiebaut, N., Xu, Y., & Gupta, A. (2022). Countergan: Generating counterfactuals for real-time recourse and interpretability using residual gans. Uncertainty in Artificial Intelligence, 1488–1497. PMLR.
Parmentier, A., & Vidal, T. (2021). Optimal counterfactual explanations in tree ensembles. International Conference on Machine Learning (pp. 8422–8431) PMLR.
Poyiadzi, R., Sokol, K., Santos-Rodriguez, R., De Bie, T., & Flach, P. (2020). Face: feasible and actionable counterfactual explanations. In Proceedings of the AAAI/ACM Conference on AI, Ethics, and Society, pp. 344–350
Raimundo, M. M., Nonato, L. G., & Poco, J. (2022). Mining pareto-optimal counterfactual antecedents with a branch-and-bound model-agnostic algorithm. Data Mining and Knowledge Discovery, 1, 33.
Redelmeier, A., Jullum, M., Aas, K., & Løland, A. (2024). Mcce: Monte carlo sampling of valid and realistic counterfactual explanations for tabular data. Data Mining and Knowledge Discovery, 38(4), 1830–1861.
Ribeiro, M.T., Singh, S., & Guestrin, C. (2016). “ Why should i trust you?” explaining the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 1135–1144
Russell, C. (2019). Efficient search for diverse coherent explanations. Proceedings of the Conference on Fairness, Accountability, and Transparency (pp. 20–28)
Samoilescu, R.-F., Van Looveren, A., & Klaise, J. (2021). Model-agnostic and scalable counterfactual explanations via reinforcement learning arXiv:2106.02597 arXiv preprint.
Schleich, M., Geng, Z., Zhang, Y., & Suciu, D. (2021). Geco: Quality counterfactual explanations in real time. Proceedings of the VLDB Endowment, 14, (9)
Shrikumar, A., Greenside, P., & Kundaje, A. (2017). Learning important features through propagating activation differences. International Conference on Machine Learning (pp. 3145–3153) PMlR.
Ustun, B., Spangher, A., & Liu, Y. (2019). Actionable recourse in linear classification. Proceedings of the Conference on Fairness, Accountability, and Transparency (pp. 10–19)
Verma, S., Boonsanong, V., Hoang, M., Hines, K., Dickerson, J., & Shah, C. (2024). Counterfactual explanations and algorithmic recourses for machine learning: A review. ACM Computing Surveys, 56(12), 1–42.
Verma, S., Hines, K., & Dickerson, J. P. (2022). Amortized generation of sequential algorithmic recourses for black-box models. Proceedings of the AAAI Conference on Artificial Intelligencex, 36, 8512–8519.
Wachter, S., Mittelstadt, B., & Russell, C. (2017). Counterfactual explanations without opening the black box: Automated decisions and the gdpr. Harv. JL & Tech., 31, 841.
Yadav, P., Hase, P., & Bansal, M. (2021). Low-cost algorithmic recourse for users with uncertain cost functions arXiv:2111.01235 arXiv preprint.
Yang, F., Alva, S.S., Chen, J., & Hu, X. (2021). Model-based counterfactual synthesizer for interpretation. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pp. 1964–1974
Yeh, I.-C. (2016). Default of credit card clients. UCI Machine Learning Repository. https://doi.org/10.24432/C55S3H
Funding
The Article Processing Charge (APC) for the publication of this research was funded by the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) (ROR identifier: 00x0ma614).
Author information
Authors and Affiliations
Contributions
A.H.M.O.: Conceptualization, Methodology of Sects. 3 and 4, Writing of Sects. 1, 2 and 3. G.V.: Conceptualization, Methodology of Sect. 5, Software, Writing. M.M.R.: Conceptualization, Supervision, Project administration, Writing—Review and Editing.
Corresponding author
Additional information
Editor: Ira Assent.
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Appendices
Appendix A: Analysis of Outlier Detection
In this section, we present an analysis of the isolation forest models used for the experiments at Sec. 5. We first present a visual analysis of the distribution of outliers. To do so, for each of the five datasets, we present a 2D projection of the training data obtained with PCA, and color points based on the classification of the outlier detection. As we use two different isolation forest models, one with cheap inference to be used internally by P\(^{2}\)CE and one more complex model to be used in the evaluation step, we display the outlier classification of both.
Figure 7 displays the results of outlier detectors. As we can see, all datasets present a “concentrated” density of inlier points, with outliers being present around it. However, certain points inside this region of inlier points were also classified as outliers. This might occur due to the projection of the original data to 2D. This projection will lose information from the original data space, which could cause some outlier points to be projected into the same region as inlier points. Furthermore, it is possible to identify certain differences between the two isolation forest models. As the isolation forest used for evaluation considers the interaction between features to build the trees, it will be able to capture more complex patterns.
Isolation forest models predict a score between 0 and 1, where values close to 1 indicates more outlierness. Then, outlier classification is made using a threshold of this score. As we explain on Sec. 5, we do not have access to the contamination rate (occurrence of outliers) of the datasets, and we use a fixed fraction of 5% of training samples being classified as outliers. In more detail, we calculate scores for all the training samples, and use the 95% percentile to select the threshold, that is, samples classified as outliers are the ones with the top 5% scores. At Table 3, we display the average score and the threshold used in evaluation by the isolation forest model.
Appendix B: Alternative Visualization of Counterfactual Explanations
We present an alternative visualization of counterfactual explanations to the same individual depicted at Sect. 5. They are presented at Fig. 8 (DiCE results) and at Fig. 9 (P\(^{2}\)CE results). In this visualization, each column represents a counterfactual explanation, with each square representing a change in feature value. For example, the first explanation presented by DiCE suggests increasing the feature “hours_per_week” from 23 to 38 and the feature “capital_gain” from 0 to 9810.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/
About this article
Cite this article
de Oliveira, A.H.M., Valdrighi, G. & Raimundo, M.M. P\(^{2}\)CE: Model-Agnostic Plausible Pareto-Optimal Counterfactual Explanations. Mach Learn 115, 213 (2026). https://doi.org/10.1007/s10994-026-07143-6
Received:
Revised:
Accepted:
Published:
Version of record:
DOI: https://doi.org/10.1007/s10994-026-07143-6
Facts Only
* P$^{2}$CE is an algorithm for generating plausible Pareto-optimal counterfactual explanations.
* The algorithm uses an isolation forest for outlier detection and SHAP values for efficiency.
* Counterfactual feasibility measures include average continuous distance, maximum continuous distance, and number of changes.
* MAPOCAM uses a branch-and-bound strategy but relies on monotonicity assumptions.
* P$^{2}$CE utilizes the Isolation Forest algorithm to identify outliers among potential solutions found in a search grid.
* The method estimates the maximum prediction ($\overline{f}a$) using SHAP values, which is applicable across various models without assuming monotonicity.
* Experiments were conducted on datasets including German Credit, Taiwan, HomeCredit, Adult, and ACS Income.
* P$^{2}$CE outperformed MAPOCAM in terms of computational time while yielding solutions with lower outlier rates.
* Multiple objectives (distance metrics, sparsity) are considered to find Pareto-optimal solutions, which are then filtered for plausibility.
Executive Summary
Full Take
Sentinel — Human
This text exhibits the high level of structured, specialized argumentation typical of a peer-reviewed research paper, suggesting it is authentically human-authored scholarly work detailing a novel algorithmic contribution.
