{'fraction_non_alphanumeric': 0.03260129383724889, 'fraction_numerical': 0.005930087390761548, 'mean_word_length': 4.620315739116569, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The Clever Hans Effect in Anomaly Detection

The 'Clever Hans' effect occurs when the learned model produces correct predictions based on the 'wrong' features. This effect which undermines the generalization capability of an ML model and goes undetected by standard validation techniques has been frequently observed for supervised learning where the training algorithm leverages spurious correlations in the data. The question whether Clever Hans also occurs in unsupervised learning, and in which form, has received so far almost no attention. Therefore, this paper will contribute an explainable AI (XAI) procedure that can highlight the relevant features used by popular anomaly detection models of different type. Our analysis reveals that the Clever Hans effect is widespread in anomaly detection and occurs in many (unexpected) forms. Interestingly, the observed Clever Hans effects are in this case not so much due to the data, but due to the anomaly detection models themselves whose structure makes them unable to detect the truly relevant features, even though vast amounts of data points are available. Overall, our work contributes a warning against an unrestrained use of existing anomaly detection models in practical applications, but it also points at a possible way out of the Clever Hans dilemma, specifically, by allowing multiple anomaly models to mutually cancel their individual structural weaknesses to jointly produce a better and more trustworthy anomaly detector.


Introduction
Anomaly detection [6,26] is a common machine learning problem for which numerous approaches have been proposed. They can be roughly organized into density-based [24,25], reconstruction-based [11,12,8], and boundary-based approaches [32,35,31,29]. Recently, there has been an effort to develop benchmarks and procedures to systematically assess and compare the performance of different anomaly detection models [9,3]. Because it is hard to conceive a representative set of anomalies that would test for all particular ways in which a point can be anomalous, common testing procedures (based on a score and some set of labeled outliers) can strongly under/overestimate the performance of a given trained anomaly detection model.
In this paper, we propose to further validate an anomaly detector by inspecting its decision structure, in particular, to ensure that the model has not unintentionally implemented a 'Clever Hans' strategy [17]. 'Clever Hans' refers to a famous horse that was believed to be able to perform arithmetic calculations asked by his trainer. Later studies have revealed, that the horse was basing its consistently correct predictions not on performing the actual mathematical calculation but on watching unintended gestures of the trainer or some other human. Similar Clever Hans effects have been observed in areas such as information retrieval [34] or supervised learning [17]. In the latter case, this typically arises from letting the learning model exploit spurious correlations in data. These spurious correlations have been predicted to become increasingly severe as datasets become larger [5], thus, making the problem increasingly relevant. To the best of our knowledge, however, this interesting effect has not yet been studied in unsupervised models such as anomaly detection.
To analyze the Clever Hans effect in the context of anomaly detection, we need to endow the anomaly detection models with explainable AI (XAI) capabilities, so that they are able to provide explanations to their own prediction, specifically, identifying input features that have contributed the most to the anomaly score. Various methods have been proposed for explaining anomaly models [19,16,14], although so far, explanation techniques do not homogeneously and reliably apply to all anomaly detection models. Also, there is a need to systematically detect Clever Hans effects from those explanations, something that has so far only been done for supervised classifiers [17].
In this paper, we address the questions above by contributing in the following distinct ways: 1. We propose to embed common anomaly detection models in a three-layer neural network architecture consisting of (i) feature extraction, (ii) distance computation and (iii) pooling. This common representation of anomaly models allows us to systematically explain their predictions in a way that is comparable across models.
2. We demonstrate in the context of anomaly detection that 'Clever Hans' effects can also be found in large amounts and in various forms. For this, we make use of the MNIST-C [22] and MVTec [3] corpora which come with ground-truth anomalies and pixel-wise annotations.
3. We analyze on a more abstract level how the Clever Hans effect systematically arises in different anomaly detection models. Unlike in supervised learning, where this effect is mainly the result of exploiting spurious correlations in the data, Clever Hans is found here to be intrinsic to the structure of the anomaly detection model. 4. Observing that each model has structural weaknesses that lead to Clever Hans strategies, we investigate a bagging approach, which we find to produce improvements compared to the individual models.
Overall, through the lens of XAI, our paper brings attention to the limitations of standard anomaly detection models, in particular, their exposure to the Clever Hans effect. While it underlines further motivation and necessity for improving current anomaly detectors, it also shows that the Clever Hans effect can be reduced via a simple bagging technique.

Towards Explainable Anomaly Detection
In the following, we introduce a common XAI framework that is applicable to a broad range of anomaly detection models by first embedding them into a layered neural network architecture, and then using the resulting layered architecture to support a common backpropagation procedure for extracting explanations. Anomaly detection models can be roughly divided into three categories: Density-Based Models Density-based anomaly detection consists of first learning a probability model on inlier data, and then measure outlierness for a new data point x based on the model probability score, e.g. o(x) = − log p θ (x). For the common kernel density estimation models [28,24] (KDE), the outlier score can be rewritten up to a constant factor and additive term as a soft min-pooling over distances When the kernel is Gaussian, the min-pooling is given as min γ j (h j ) = −γ −1 log j exp(−γ h j ), i.e. an inverted log-sum-exp pooling with stiffness γ. When the kernel is t-Student, the min-pooling takes the form of a harmonic mean [14]. A similar min-pooling formulation can be obtained for other types of density models such as Gaussian mixture models.
Reconstruction-Based Models Reconstruction is another paradigm for anomaly detection [11,12,8], where the outlier score is given as the divergence between the original data and its reconstruction, for example given by an autoencoder x → r(x). Typically, the outlier score is given by the squared reconstruction distance: When the autoencoder output is not deterministic and produces instead a conditional distribution p θ (x | r(x)) at the output, outlierness can be measured as the negative logprobability, and when the conditional distribution is Gaussian, it becomes equivalent to the squared distance.
Boundary-Based Models Boundary-based models learn an envelope that contains the inliers. Data points outside the envelope are then predicted to be outliers. The envelope or decision boundary can be built in input space, e.g. as in the one-class SVM [32] or Support Vector Data Description [35], but also in feature space, e.g. in deep one-class classification [29]. A deep one-class model typically builds a spherical envelope in feature space by defining the outlier score where the feature map is trained to minimize this quantity for inliers, subject to some regularization constraint. Interestingly, boundary-based models are not restricted to unsupervised data and can instead leverage supervised outlier data to refine the decision boundary [10,1,30].
We have briefly reviewed three families of methods for outlier detection: density-based, reconstruction-based, and boundary-based. Although these methods may appear to be different in all technical aspects, we find that outlier scores produced by each of them can in fact be conceptually embedded in the same three-layer architecture: (1) Feature extraction: Features that are considered to be relevant for the task of anomaly detection are extracted or made more salient in the feature map representation. (This step is only present in the deep one-class model). (2) Distances: Distances to some template(s) are then produced. Templates are either the data distribution itself for the KDE model, the autoencoder reconstruction for the reconstruction-based model, or the origin in feature space for the deep one-class model. (3) Pooling: Produced distances are then pooled using some common pooling function (this step is only present in the KDE model). The way each model fits in this three-layer architecture is shown in Figure 1.  This architecture lets us build an explanation technique that homogeneously applies to all three models. Our approach to explanation is based on the framework of 'Deep Taylor Decomposition' [20,14], where a Taylor expansion is applied at each layer to identify the most contributing terms in the lower layer. Overall, the method leads to an LRP-type [2] backward propagation procedure from the output score to the input features. Propagation in the different layers is detailed below.
Pooling Layer Let o((s k ) k ) be some function performing the pooling. We identify a 'deactivation' line in the space of pooled elements on which the pooling function is linear. We then select the root point ( s k ) k on that line, i.e. where the output of the pooling becomes zero. Finally, the attribution is given by the elements of a first-order Taylor expansion at the root point, i.e. R k = [∇o( s)] k · (s k − s k ). To further propagate to the lower layers, we can approximate the attribution as a homogeneous function of the pooled activations, i.e. R k = c k s k .
Distance Layer When attribution hits the distance layer, the output must be further redistributed to different dimensions entering in the distance computation. Here, we express the score we have obtained in the layer above in terms of the distance inputs: R k (a) = c k j (a jk − µ jk ) 2 . The variable µ jk is either constant (KDE and Deep) or is treated as such (Autoencoder). A second-order Taylor expansion at the origin gives diagonal second-order terms: Features Layer To further propagate the decomposition throughout the network, we need µ = 0 (i.e. the outlier model is centered at the origin), which lets us express the terms from the layer above as R jk = c k φ jk (x) 2 . This quantity can be propagated to the input features using standard LRP [2].
Further explanations and justification for these propagation steps are given in Appendix A of the Supplement. Finally, when compared to other approaches, especially sampling-based approaches, which do not rely on the underlying model structure [19,27], the propagationbased approach we have developed here is faster (it requires only a single pass in the model) and also does not require access to the input distribution.

Unmasking Clever Hans Effects in Anomaly Models
Having equipped anomaly detection models with a systematic way of explaining their predictions in terms of input features, we will now look for possible Clever Hans effects in these anomaly models, especially when the latter are applied to real data.
Our experiments are performed on two recent datasets: MNIST-C [22], and MVTec [3]. A peculiarity of these two datasets which makes them ideal testbeds is that they either come with the data generation process (from which ground-truth explanations of anomalies can be built) or with ground-truth pixel-wise annotations of the anomaly patterns.
For each dataset, we train three models: A kernel density estimator (KDE), an autoencoder (Auto), and a deep one-class model (Deep). For the KDE model, we use a Gaussian kernel where we select the scale such that the likelihood of an inlier validation set is maximized. For the autoencoder on MNIST-C, we use a LeNet-type encoder that has two convolutional layers with max-pooling followed by two fully connected layers that map to an encoding of 64 dimensions. We construct the decoder symmetrically where we replace convolution and max-pooling with deconvolution and upsampling respectively. For MVTec, we use an encoder-decoder architecture as presented in [13] which maps to a bottleneck of 512 dimensions. Both, the encoder and decoder here consist of four blocks having two 3×3 convolutional layers followed by max-pooling or upsampling respectively. We train the autoencoders using the Adam optimizer [15] such that the reconstruction error of an inlier validation set is minimized. The Deep One-Class model is built on top of the feature extractor of a CNN. For MNIST-C, we train a classifier CNN on the 'letters' subset of the EMNIST dataset [7]. The feature extractor consists of three convolutional layers that are interleaved with 2 pooling layers, leading to a 640 dimensional feature space. For MVTec, we start with a standard pretrained VGG-16 network [33] and we cut off the top classification layer, which results in a 4096 dimensional feature space. For both models, the outlier score is defined to be the squared norm of the feature vector after a linear whitening transformation that is regularized such that the outlier detection ROC score on a validation set with some outliers is maximized.
The detection performance for each class, model and dataset are shown in Figure 2.  On the MNIST-C dataset, the autoencoder delivers the best results, however, there are exceptions to this, for example, scale, rotation, or translations are better detected by the deep one-class model. On the MVTec dataset, the deep one-class model performs best on most classes, which can be explained by the more abstract level and multiscale properties present in this dataset. The question we ask is whether the results are truly reliable or whether some of the accuracies are compromised due to the Clever Hans effect.

MNIST-C
Here, we leverage the fact that for the two considered datasets, MNIST-C and MVTec, ground-truth pixel-wise annotations are given and can therefore be confronted with the pixel-wise explanations of the model predictions. We can define a score measuring the mismatch between the detection accuracy (measured as the area under the ROC curve) and the explanation accuracy (measured as the cosine similarity between the ground-truth and the pixel-wise explanation). Pixel-wise explanations are passed through a rectification function so that the cosine similarity is always greater or equal to zero. We define the Clever Hans score as the difference: Clever Hans score = detection accuracy − explanation accuracy The Clever Hans score is a number which ranges from −1 to 1 (or −100 and 100 if expressed on a percentage scale). The closer to 100, the more the anomaly detector has fooled the standard validation procedure by exploiting the wrong input features. In particular, we will look for anomaly detection models and tasks with highest Clever Hans scores to highlight the widespread presence of this effect in anomaly detection. Figure 3 shows the top-3 classes with highest Clever Hans scores for each model and dataset.
Highest Clever Hans scores are obtained for the MVTec dataset which is also a more difficult and high-dimensional anomaly detection problem. It is also notable that different classes appear in the top-3 for the different models, suggesting that the models are affected by the problem in different ways. To shed light on the diverse Clever Hans effects, we look at single instances from classes in the top-3. Examples for each model and dataset are given in Figure 4.
We observe for example on MNIST-C, that the KDE model, although correctly identifying the anomalous dotted pattern, also highlights the whole digit region. The same occurs for the wood class on the MVTec dataset, where the high-frequency wood stripes appear as anomalous and completely dominate the small local perforations on the wood that are the true sources of anomaly.   Similar Clever Hans effects can be observed for the autoencoder, in particular, for the MNIST-C canny edges transformation. Here, although the whole interior of the digit has turned from white to black, the autoencoder completely ignores that change of color and only highlights the contour of the digit. On MVTec, a large contamination is present at the center of the bottle (photographed from above), however, the autoencoder bases its anomaly prediction on very fine elements on the outer part of the bottle.
Clever Hans effects can also be observed for the deep one-class model. The MNIST-C stripe transformation makes the whole border of the image turn from black to white, however, the deep one-class model bases its decision only on the edges of the added stripes and the interaction between these edges and the digit. On the MVTec data, the decision is mostly based on looking at the transition between the zipper tissue and the white background, rather than attending the true source of anomaly which is the zipper opening.
In all the examples above, the anomaly model has produced high outlier scores, but these high scores were produced systematically for the 'wrong' reasons. These Clever Hans strategies potentially undermine the generalization capability of the models, even for the classes with the highest measured anomaly detection accuracy.

Understanding Why Anomaly Models are Clever Hanses
In practice, it is not feasible to inspect the explanation of every new prediction. We thus need to attain more systematic insights into what conceptually and theoretically causes these Clever Hans strategies. Because the observed effects manifest themselves in various ways for the different models, we hypothesize that they are inherent to the structure of the anomaly detection models, rather than a petty effect of the training data. In the following, we give explanations for why the Clever Hans effect arises systematically in these models, and connect them to the effects observed in Fig. 4.

Kernel Density Estimation:
We propose an explanation of the Clever Hans effect in KDE, based on the concentration of distances phenomenon occurring in high-dimensional spaces [36]. In such spaces, distances between different pairs of data points (assumed to be sampled randomly) become increasingly similar, i.e. their deviation from the mean converges to zero. By rewriting the KDE model of Eq. (1) as whered indicates the average distance to the inliers, and making use of the linear approximations exp(t) = 1 + t and log(N + t) = log(N ) + t/N at t = 0, the KDE outlier score can be approximated as wherex denotes the mean of the inliers (cf. Appendix B in the Supplement for a derivation). This result suggests that in effect, KDE implements a difference-to-the-mean anomaly detection strategy in the input space. This strategy is also revealed by the heatmaps in Fig.  4 where the difference-to-the-mean component (the digit area and the wood stripes) explains a greater fraction of the KDE outlier score than to the true anomalies (the dotted line and the wood perforations).
Autoencoder Reconstruction: For this model, the Clever Hans effect finds its source in data points x whose reconstruction r(x) lies far away from the true data distribution. Hence, the difference x − r(x) which supports the construction of the outlier score, is mainly supported by features that do not connect in any meaningful way to the input distribution and are therefore irrelevant for explaining anomaly. This weakness is also revealed by the heatmap explanations in Fig. 4. The MNIST-C canny-edge transformation brings the data point in a completely different region of the input space, where the reconstruction-based explanation focuses on edges rather than focusing on the global transformation of the digit from white to black. A similar effect is observed on the MVTec data for the class bottle, where the large contamination artefact at the center of the image can be more easily reconstructed than some non-anomalous patterns at the border of the bottle, therefore, misidentifying again the true source of outlierness.
Deep One-Class: Deep models measure outlierness as the distance in some feature space different from the input space o(x) = φ(x)−φ(x ) 2 . Typically, the feature map incorporates feature weightings, activation units, and pooling steps that produce distortions on the local input geometry. While such distortions are desirable in supervised learning to build invariance and gain statistical efficiency, it almost surely also compresses a few of the many components in which an anomaly could occur. This phenomenon can be clearly seen in the explanations of Fig. 4: For the MNIST-C example, the outer border of the explanation is zero although the stripe outlier pattern extends to the very border of the image. Similarly, on the MVTec example, the deep network attends the border of the zipper fabric much more strongly than the center area where the true anomaly can be found. The weaknesses of these different anomaly detection techniques and the Clever Hans strategies they induce are summarized as a cartoon in Fig. 5. The KDE model builds a hypersphere centered at the data mean. The autoencoder builds some reconstruction manifold (here from top to bottom) and the outlier score is given as the distance to that manifold. Finally, the deep model learns a separating surface between the inliers and outliers, whose orientation is strongly affected by the learned feature map. While in this cartoon example all the data is correctly predicted, the explanations, here depicted as an orthogonal projection on the decision boundary, are strongly influenced by the structure of the model. Clever Hans predictions are highlighted in red and correspond to examples whose explanation deviates significantly from the ground-truth explanation.
To summarize, we have argued that flaws on the decision structure revealed by our explanation technique are mostly the consequence of model limitations and biases. This finding substantially differs from the study of Clever Hans in the context of supervised learning where it was found that such effect was rather induced by spurious correlations in the data [17].

Improving Prediction with a Bag of Clever Hanses
Motivated by the structural weaknesses of individual anomaly detection models, we discuss a simple improvement consisting of bagging these individual detectors to arrive at a better and more robust prediction strategy. Several works on bagging anomaly detectors have delivered encouraging results [18,23]. The bagged model we consider here computes where the outlier scores of each individual model have been standardized over the training examples of the given class to have mean 0 and variance 1. The bagging can be understood as a soft max-pooling over outlier scores. It effectively implements a disjunction (i.e. logical 'OR') of all outlier areas of the individual models. A geometrical motivation for this strategy can be found in Figure 5, where the resulting area would closely match the ground-truth outlier area shown on the left. We test the bagging approach on the MVTec dataset. Using the bagged outlier score obtained from averaging the standardized scores of individual models, we again compute the ROC detection score for each class. Because the bagged model simply adds an average pooling layer, it still fits in the 3-layer feature / distance / pooling architecture presented in Section 2, and we can therefore also compute the explanations and the Clever Hans score. ROC and Clever Hans scores averaged over all classes are plotted for each model in Figure 6 (left).
Looking only at the ROC score, the bagged model appears to be outperformed by the deep model. However, a closer inspection reveals that the higher measured detection performance of the deep model comes along with stronger Clever Hans effects. Taking both factors into consideration, the bagged model ranks first among all four models. explanations produced by each model on the same images as in Fig. 4. We observe that although relatively far from the ground-truth, explanations for the bagged model comprise a broader range of feature types compared to individual models, hence, pixels used for the decision more frequently overlap with the truly anomalous pixels. This wider support for the detection task should consequently translate into a better generalizing model.

Conclusion
The 'Clever Hans' effect has been often observed in the context of supervised classifiers. In this work, we demonstrated that this effect also occurs in unsupervised learning, specifically, in anomaly detection. Through a newly contributed XAI procedure highlighting relevant features for each anomaly model and a way of quantifying the Clever Hans effect based on matching pixel-wise ground-truth annotations, our work has revealed the widespread occurrence of Clever Hans phenomena in anomaly detection models, additionally exhibiting a wealth of forms such effect can assume in practice. Furthermore, our analysis has revealed that the Clever Hans effect can be mainly attributed to the structure of the anomaly detection models rather than the data itself.-In fact, the same could be said about the original 'Clever Hans' horse when faced with arithmetic calculations: Even if the horse would have seen many mathematical formulas along with their correct answer (including cases where the trainer was not there!), the horse would still be unable to learn the proper problem representation as he is structurally unable to do so. He would therefore invariably continue to predict as a 'Clever Hans'. Interestingly, every anomaly detection model in our study exhibits Clever Hanses reasoning at least in some cases, and each of them does so in its own particular way. While our work warns against an unreflected use of anomaly detection models in practice, especially for safety-critical tasks, it also sheds a more optimistic note on the problem, specifically, we have demonstrated that a simple bagging approach combining the various Clever Hans models can reduce the Clever Hans effect and lead to sensibly improved results. Future work will aim to go beyond simple bagging to develop new and structurally less rigid models in order to avoid Clever Hans strategies and further improve generalization performance.

A Details on LRP-Based Anomaly Explanation
In the following, we give some background on the layer-wise relevance propagation (LRP) [2] approach to explanation, and more specifically, details and justification for the procedure we use in the paper to explain anomalies. LRP is an explanation technique that leverages the internal structure of neural networks to ease the process of explanation. LRP operates by performing a purposely designed backward pass in the neural network from the output to the input. The backward pass can be derived from the framework of deep Taylor decomposition (DTD) [20]. The LRP method was later on extended to other models, e.g. kernel-based anomaly detection [14], where one first needs to perform a preliminary 'neuralization' step which transforms the model into an equivalent neural network. In the present work, we have generalized the approach to a broader family of anomaly detection models. The neural network equivalents of considered models are shown in Table 1.  Figure 7 illustrates the LRP approach. The derivation of the backward pass with DTD is based on a relevance function R k (a) and its Taylor expansion gives the messages R j←k to propagate backwards. Because the function R k (a) can be complex, it is typically substituted by a relevance model R k (a) = a k (a) · c k with c k constant. Thus, in the following, we discuss for each layer type encountered in our anomaly detection models: 1. For the analyzed relevance model, how to choose an appropriate root point a at which to perform the Taylor expansion so that meaningful messages R j←k can be extracted.
2. Whether the redistributed messages R j←k (or their aggregation R j = k R j←k ) are structured in a way that an appropriate relevance model can be built to iterate the propagation procedure one layer below.
We start the discussion with the pooling layers, and then continue with the distance layer and finally the feature layers of the deep network.

A.1 Propagation in Average Pooling Layers
Average pooling layers are defined as: where N is the number of neurons in the pool. We assume that the relevance R k attributed to the output of the pool is appropriately described by the relevance model: with c k constant. The relevance model can be expanded at the root point a = 0, which gives us the first-order terms: defining how much of the relevance in R k must be redistributed on the neurons of the layer below.
As a second step, we would like to verify that the lower-layer relevances are structured in a way that they support a suitable model for propagation in the layer below. Here, we note that R j←k = a j · c k /N cj where c j can again be treated as constant.

A.2 Propagation in Negative Log-Sum-Exp Layers
We consider a negative log-sum-exp pooling a k (a) = smin j γ {a j } where we have used the notation smin γ j {a j } = −γ −1 log N j=1 exp(−γ a j ), and where γ is the stiffness parameter. Like for average pooling, we assume the relevance to redistribute can be modeled as R k (a) = a k (a) · c k with c k constant. A first-order Taylor expansion at the root point a = a − a k 1 gives the first-order terms [14]: where we have used the notation sargmin γ j {a j } = exp(−γ · a j )/ j exp(−γ · a j ). This expression can be further developed to let appear a j as a factor: When γ → ∞ (and assuming that elements in the pool have different values), the term p k becomes locally constant and the θ k converges to zero (a proof is given in [14]). This limit result gives support for treating the two terms as constant and zero respectively when propagating to the lower layers, and therefore, a suitable relevance model can be built for the layer below.

A.3 Propagation in Squared Distance Layers
Distance layers considered in the main text have the form a k (a) = a − µ k 2 Again, we assume we can build a relevance model of the type R k (a) = a k (a) · c k with c k constant, and we also treat µ k to be constant. Here, the function is quadratic, hence, decomposition can only be achieved by performing a second-order Taylor expansion. Choosing the root point a = µ k yields the second-order terms [14]: When each input feature contributes to several distances (e.g. the distances to the multiple training points in KDE), relevance scores can be aggregated as: R j = k R j←k . When there is only a single distance and this distance is w.r.t. the origin (as for the deep model considered in the main text), the equation above reduces to R j ← c k a 2 j . In the case of the deep model, the relevance score needs to be further propagated through the multiple layers of features.

A.4 Transition from Distance to Feature Layers
The last layer of features in the deep model is a linear whitening layer, whose output neurons can be simply written as: a k (a) = j a j w jk Relevance coming from the distance layer above has the form R k (a) = (a k (a)) 2 c k with c k approximately locally constant. Hence, combining the two equations, we can build the relevance model R k (a) = j a j w jk 2 c k with c k constant. However, because of the squaring operation, it is difficult to extract simple messages R j←k to redistribute to the layer below. Instead, we observe that the relevance model can be decomposed into an infinite sum of piecewise linear relevance models: R kτ (a) = max(0, j a j w jk sign(a k ) − τ ) · 2∆τ · c k with small intervals ∆τ . These relevance models jointly sum to the original relevance model (i.e. τ ∈{0,∆τ,2∆τ,... } R kτ (a) ≈ R k (a)). For all of these models, there is a root point on the interval [0, a], and choosing a very close to the root point but still on the activated domain gives the directional redistribution: Finally, summing over τ gives: As a last step, we need to verify that the scores R j←k , or more precisely, the aggregated score R j = k R j←k support an appropriate relevance model for the layer below. We observe that the relevance can be restructured as: R j = a j · k w jk j a j w j k 2 j a j w j k c k = a j · k w jk j a j w j k c k = a j c j where we have a j appearing as a linear term, and c j a term that depends on a j but only through a nested sum involving many other activations, hence diluting the dependency.

A.5 Propagation in Feature Layers
Deep neural networks used in this work are composed of a succession of Linear/ReLU layers of the type a k (a) = max 0, j a j w jk Again, we assume the model is given as a multiple of the output activation, i.e.
R k (a) = a k (a) · c k = max 0, j a j w jk · c k .
The function is linear with a on the activated domain. A root point can be found on the segment a ∈ {a − t · a (1 + γ · 1 w k 0 ) | t ∈ R} where γ is a hyper-parameter between 0 and ∞, and 1 {·} is an indicator function applied element-wise. Performing a Taylor expansion at this root point, more exactly, very close to the root point but still in the activated domain, gives the first-order terms [21]: The higher the parameter γ, the more preference is given to the positive contributions to support the explanation. Empirically, this also leads to explanations that are more robust to the high nonlinearity [21]. Finally, we need to verify that a suitable relevance model can be built for the layer below. We observe that relevance in that layer can be written as R j = a j · k (w jk + γw + jk ) max(0, j a j w jk ) j a j (w j k + γw + j k ) c k = a j c j where similarly to Section A.4, we can use the nested sums argument to justify the treatment of c j as constant in the relevance model of the layer below. For further details on how to propagate relevance in the various layers of a deep neural network, see [21].

B Behavior of KDE for High-Dimensional Data
High-dimensional input spaces are subject to the effect of concentration of distances, where distances between different randomly sampled vectors become similar [4,36]. Here, we show that under such effect, the KDE model for outlierness becomes approximately a simple distance-to-the-mean function, i.e.
To show the above, we decompose the distances as: x − x j 2 =d + ( x − x j 2 −d) i.e. a mean distance (over all data points (x j ) N j=1 ), and a deviation from the mean, which according to the concentration of distances effect becomes small. Taking the KDE outlier function, and making use of the approximations exp(t) = 1+t and log(N +t) = log(N )+t/N , which are valid when t is close to 0, we start from the KDE model and arrive at the stated reduction.