Perfect density models cannot guarantee anomaly detection

1 INTRODUCTION . Several machine learning methods aim at extrapolating a behavior observed on training data in order to produce predictions on new observations . But every so often , such extrapolation can result in wrong outputs , especially on points that we would consider infrequent with respect to the training distribution . Faced with unusual situations , whether adversarial ( Szegedy et al. , 2013 ; Carlini & Wagner , 2017 ) or just rare ( Hendrycks & Dietterich , 2019 ) , a desirable behavior from a machine learning system would be to flag these outliers so that the user can assess if the result is reliable and gather more information if need be ( Zhao & Tresp , 2019 ; Fu et al. , 2017 ) . This can be critical for applications like medical decision making ( Lee et al. , 2018 ) or autonomous vehicle navigation ( Filos et al. , 2020 ) , where such outliers are ubiquitous . What are the situations that are deemed unusual ? Defining these anomalies ( Hodge & Austin , 2004 ; Pimentel et al. , 2014 ) manually can be laborious if not impossible , and so generally applicable , automated methods are preferable . In that regard , the framework of probabilistic reasoning has been an appealing formalism because a natural candidate for outliers are situations that are improbable or out-of-distribution . Since the true probability distribution density p∗X of the data is often not provided , one would instead use an estimator , p ( θ ) X , from this data to assess the regularity of a point . Density estimation has been a particularly challenging task on high-dimensional problems . However , recent advances in deep probabilistic models , including variational auto-encoders ( Kingma & Welling , 2014 ; Rezende et al. , 2014 ; Vahdat & Kautz , 2020 ) , deep autoregressive models ( Uria et al. , 2014 ; van den Oord et al. , 2016b ; a ) , and flow-based generative models ( Dinh et al. , 2014 ; 2016 ; Kingma & Dhariwal , 2018 ) , have shown promise for density estimation , which has the potential to enable accurate density-based methods ( Bishop , 1994 ) for anomaly detection . Yet , several works have observed that a significant gap persists between the potential of density-based anomaly detection and empirical results . For instance , Choi et al . ( 2018 ) , Nalisnick et al . ( 2018 ) , and Hendrycks et al . ( 2018 ) noticed that generative models trained on a benchmark dataset ( e.g. , CIFAR-10 , Krizhevsky et al. , 2009 ) and tested on another ( e.g. , SVHN , Netzer et al. , 2011 ) are not able to identify the latter as out-of-distribution with current methods . Different hypotheses have been formulated to explain that discrepancy , ranging from the curse of dimensionality ( Nalisnick et al. , 2019 ) to a significant mismatch between p ( θ ) X and p ∗ X ( Choi et al. , 2018 ; Fetaya et al. , 2020 ; Kirichenko et al. , 2020 ; Zhang et al. , 2020 ) . In this work , we propose a new perspective on this discrepancy and challenge the expectation that density estimation should enable anomaly detection . We show that the aforementioned discrepancy persists even with perfect density models , and therefore goes beyond issues of estimation , approximation , or optimization errors ( Bottou & Bousquet , 2008 ) . We highlight that this issue is pervasive as it occurs even in low-dimensional settings and for a variety of density-based methods for anomaly detection . 2 DENSITY-BASED ANOMALY DETECTION . 2.1 UNSUPERVISED ANOMALY DETECTION : PROBLEM STATEMENT . Unsupervised anomaly detection is a classification problem ( Moya et al. , 1993 ; Schölkopf et al. , 2001 ) , where one aims at distinguishing between regular points ( inliers ) and irregular points ( outliers ) . However , as opposed to the usual classification task , labels distinguishing inliers and outliers are not provided for training , if outliers are even provided at all . Given a input space X ⊆ RD , the task can be summarized as partitioning this space between the subset of outliers Xout and the subset of inliers Xin , i.e. , Xout ∪ Xin = X and Xout ∩ Xin = ∅ . When the training data is distributed according to the probability measure P ∗X ( with density p ∗ X 1 ) , one would usually pick the set of regular points Xin such that this set contains the majority ( but not all ) of the mass ( e.g. , 95 % ) of this distribution , i.e. , P ∗X ( Xin ) = 1− α ∈ ( 1 2 , 1 ) . But , for any given α , there exists in theory an infinity of corresponding partitions into Xin and Xout ( see Figure 1 ) . How are these partitions defined to match our intuition of inliers and outliers ? We will focus in this paper on recently used methods based on probability density . 2.2 DENSITY SCORING . When talking about outliers , infrequent observations , the association with probability can be quite intuitive . For instance , one would expect an anomaly to happen rarely and be unlikely . Since the language of statistics often associate the term likelihood with quantities like p ( θ ) X ( x ) , one might consider an unlikely sample to have a low ” likelihood ” , that is a low probability density p∗X ( x ) . Conversely , regular samples would have a high density p∗X ( x ) following that reasoning . This is an intuition that is not only prevalent in several modern anomaly detection methods ( Bishop , 1994 ; Blei et al. , 2017 ; Hendrycks et al. , 2018 ; Kirichenko et al. , 2020 ; Rudolph et al. , 2020 ; Liu et al. , 2020 ) but also in techniques like low-temperature sampling ( Graves , 2013 ) used for example in Kingma & Dhariwal ( 2018 ) and Parmar et al . ( 2018 ) . The associated approach , described in Bishop ( 1994 ) , consists in defining the inliers as the points whose density exceed a certain threshold λ > 0 ( for example , chosen such that inliers include a predefined amount of mass , e.g. , 95 % ) , making the modes the most regular points in this setting . Xout and Xin are then respectively the lower-level and upper-level sets { x ∈ X , p∗X ( x ) ≤ λ } and { x ∈ X , p∗X ( x ) > λ } ( see Figure 2b ) . 1We will also assume in the rest of the paper that for any x ∈ X , p∗X ( x ) > 0. x p ∗ X ( x ) ( a ) An example of a distribution density p∗X . x λ ( b ) Density scoring method applied to the distribution p∗X . x e −H ( p∗X ) ( c ) Typicality test method ( with one sample ) applied to the distribution p∗X . Figure 2 : Illustration of different density-based methods applied to a particular one-dimensional distribution p∗X . Outliers are in red and inliers are in blue . The thresholds are picked so that inliers include 95 % of the mass . In Figure 2b , inliers are considered as the points with density above the threshold λ > 0 while in Figure 2c , they are the points whose log-density are in the -interval around the negentropy −H ( p∗X ) . 2.3 TYPICALITY TEST . The Gaussian Annulus theorem ( Blum et al. , 2016 ) ( generalized in Vershynin , 2019 ) attests that most of the mass of a high-dimensional standard Gaussian N ( 0 , ID ) is located close to the hypersphere of radius √ D. However , the mode of its density is at the center 0 . A natural conclusion is that the curse of dimensionality creates a discrepancy between the density upper-level sets and what we expect as inliers ( Choi et al. , 2018 ; Nalisnick et al. , 2019 ; Morningstar et al. , 2020 ; Dieleman , 2020 ) . This motivated Nalisnick et al . ( 2019 ) to propose another method for testing whether a point is an inlier or not , relying on a measure of its typicality . This method relies on the notion of typical set ( Cover , 1999 ) defined by taking as inliers points whose average log-density is close to the average log-density of the distribution ( see Figure 2c ) . Definition 1 ( Cover , 1999 ) . Given independent and identically distributed elements ( x ( n ) ) n≤N from a distribution with density p∗X , the typical set A ( N ) ( p∗X ) ⊂ XN is made of all sequences that satisfy : ∣∣∣∣∣H ( p∗X ) + 1N N∑ n=1 log p∗X ( x ( n ) ) ∣∣∣∣∣ ≤ , where H ( X ) = −E [ log p∗X ( X ) ] is the ( differential ) entropy and > 0 a constant . This method matches the intuition behind the Gaussian Annulus theorem on the set of inliers of a high-dimensional standard Gaussian . Indeed , using a concentration inequality , we can show that limN→+∞ ( P ∗ ( Xi ) 1≤n≤N ( A ( N ) ) ) = 1 , which means that with N large enough , A ( N ) ( p∗X ) will contain most of the mass of ( p∗X ) N , justifying the name typicality . 3 THE ROLE OF REPARAMETRIZATION . Given the anomaly detection problem formulation Subsection 2.1 , we are interested in reasoning about the properties a solution ought to satisfy , in the ideal case of infinite data and capacity . For density-based methods this means that p ( θ ) X = p ∗ X . This setting is appealing as it gives space for theoretical results without worrying about the underfitting or overfitting issues mentioned by Hendrycks et al . ( 2018 ) ; Fetaya et al . ( 2020 ) ; Morningstar et al . ( 2020 ) ; Kirichenko et al . ( 2020 ) ; Zhang et al . ( 2020 ) . Although we work in practice on points ( e.g. , vectors ) , it is important to keep in mind that these points are actually representations of an underlying outcome . As a random variable , X is by definition the function from this outcome ω to the corresponding observation x = X ( ω ) . However , at its core , an anomaly detection solution aims at classifying outcomes through these measurements . How is the 0.0 0.2 0.4 0.6 0.8 1.0 0.6 0.8 1.0 1.2 1.4 x p ∗ X ( x ) ( a ) An example of a distribution density p∗X . 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 x f ( x ) ( b ) Example of an invertible function f from [ 0 , 1 ] to [ 0 , 1 ] . 0.0 0.2 0.4 0.6 0.8 1.0 0.6 0.8 1.0 1.2 1.4 f ( x ) p ∗ f ( X ) ( f ( x ) ) ( c ) Resulting density p∗f ( X ) from applying f to X ∼ p∗X as a function of the new axis f ( x ) . Figure 3 : Illustration of the change of variables formula and how much the application of a bijection can affect the density of the points considered in a one-dimensional case . In Figures 3a and 3c , points x with high density p∗X ( x ) are in blue and points with low density p ∗ X ( x ) are in red . choice of X affecting the problem of anomaly detection ? While several papers studied the effects of a change of representation through the lens of inductive bias ( Kirichenko et al. , 2020 ; Zhang et al. , 2020 ) , we investigate the more fundamental effects of reparametrizations f . To sidestep concerns about loss of information ( Winkens et al. , 2020 ) , we study the particular case of an invertible map f . The measurements x = X ( ω ) and f ( x ) = ( f ◦ X ) ( ω ) represent the same outcome ω ( although differently ) , and , since x and f ( x ) are connected by an invertible transformation f , the same method applied respectively to X or f ( X ) should classify them with the same label , either as an inlier or an outlier . The target of these methods is to essentially assess the regularity of the outcome ω . From this , we could ideally make the following requirement for a solution to anomaly detection . Principle . In an infinite data and capacity setting , the result of an anomaly detection method should be invariant to any continuous invertible reparametrization f . Do density-based methods follow this principle ? To answer that question , we look into how density behaves under a reversible change of representation . In particular , the change of variables formula ( Kaplan , 1952 ) ( used in Tabak & Turner , 2013 ; Dinh et al. , 2014 ; Rezende & Mohamed , 2015 ) , formalizes a simple intuition of this behavior : where points are brought closer together the density increases whereas this density decreases when points are spread apart . The formula itself is written as : p∗f ( X ) ( f ( x ) ) = p∗X ( x ) ∣∣∣∣ ∂f∂xT ( x ) ∣∣∣∣−1 , where ∣∣∣ ∂f∂xT ( x ) ∣∣∣ is the Jacobian determinant of f at x , a quantity that reflects a local change in volume incurred by f . Figure 3 already illustrates how the function f ( Figure 3b ) can spread apart points close to the extremities to decrease the corresponding density round 0 and 1 , and , as a result , turns the density on the left ( Figure 3a ) into the density on the right ( Figure 3c ) . With this example , one can wonder to which degree an invertible change of representation can affect the density and the anomaly detection methods presented in Subsections 2.2 and 2.3 that use it .

Summary: Detecting anomalies is a notoriously ill-defined problem. The notion of anomaly is not a rigorous concept and different algorithms produce different results. The paper critiques a broad set of methods which involve likelihood (or density) estimations. It's main idea revolves around the 'Principle' set on Page 4. The principle claims that when data capacity and computational constraints are removed, an AD algorithm should be invariant to 'reparametrization' of the input. Roughly speaking, that means the algorithm should be invariant to arbitrary 'name changing' of the input - the result should not change if each data item x is replaced by f(x) if f is invertible.