Testing For Typicality with Respect to an Ensemble of Learned Distributions

Good methods of performing anomaly detection on high-dimensional data sets are needed , since algorithms which are trained on data are only expected to perform well on data that is similar to the training data . There are theoretical results on the ability to detect if a population of data is likely to come from a known base distribution , which is known as the goodness-of-fit problem , but those results require knowing a model of the base distribution . The ability to correctly reject anomalous data hinges on the accuracy of the model of the base distribution . For high dimensional data , learning an accurate-enough model of the base distribution such that anomaly detection works reliably is very challenging , as many researchers have noted in recent years . Existing methods for the goodness-of-fit problem do not account for the fact that a model of the base distribution is learned . To address that gap , we offer a theoretically motivated approach to account for the density learning procedure . In particular , we propose training an ensemble of density models , considering data to be anomalous if the data is anomalous with respect to any member of the ensemble . We provide a theoretical justification for this approach , proving first that a test on typicality is a valid approach to the goodness-of-fit problem , and then proving that for a correctly constructed ensemble of models , the intersection of typical sets of the models lies in the interior of the typical set of the base distribution . We present our method in the context of an example on synthetic data in which the effects we consider can easily be seen . 1 INTRODUCTION . Machine learning models are inherently non-robust to distributional shift , and at no fault of the model necessarily . There is no reason to expect that models should perform well on data that is dissimilar to the data on which they were trained . Interestingly , despite the fact that researchers and practitioners have been able to train models that perform exceptionally well on a variety of challenging tasks , we are still bad at reliably predicting when those models will fail . This implies that not only will the models have undefined behavior on out-of-distribution data , we are unable to detect when the models are presented with out-of-distribution data . This poses a conundrum , since we wish to deploy our high-performing models , yet often we can ’ t since they can potentially have unpredictable behavior at unpredictable instances . Since training a model that is robust to all possible distributional shifts the model might encounter is potentially impossible , a more modest approach might be to come up with ways for detecting out-of-distribution data . These detections could then act as an indication that the model might be incorrect . This ability to predict incorrectness can go a long way in making systems more reliable . The problem of detecting out-of-distribution data has a long history , and is formally known as the goodness-of-fit problem . Statisticians have proved bounds on the probability of detecting populations of out-of-distribution data , such as in Barron ( 1989 ) and Balakrishnan et al . ( 2019 ) . These type of bounds show that certain tests can be performed which are capable of discerning ( with non-trivial probability ) that populations of data sampled from distributions at least some positive distance away from the base distribution are anomalous . However , in order to perform the proposed tests , an explicit form of the probability density function ( or probability mass function ) describing the base distribution is needed . For most real-world data sets , this density is not known , and must be esti- mated . While there has been a lot of analysis on the ability to detect anomalous data , those analyses typically do not account for the fact that the base density for which the tests are designed is learned . Empirically , however , many researchers have noted that detecting anomalous data in high dimensions using learned densities is hard , even when using modern , powerful density estimators . For example , the researchers in Nalisnick et al . ( 2018 ) and Choi & Jang ( 2018 ) both claim that state-ofthe-art learned densities are not suitable for anomaly detection since they assign higher probability to some out-of-distribution data than the data on which the models were trained . The authors in Nalisnick et al . ( 2019 ) realized that such a phenomenon is actually not cause for alarm , and is even expected with high-dimensional distributions . Therefore they propose performing an anomaly detection test based on the typicality of data under the learned density instead of the likelihood of data under the learned density . However , in that work , the authors noted such a test still performed poorly in some cases . In this article , we investigate why goodness-of-fit tests are challenging when using learned densities . In particular , we analyze how the typical set of learned distributions relates to the typical set of the ground truth distribution . In order to do this , we work with synthetic distributions in which the probability density function is known exactly . The contributions we make are summarized as the following : • We prove error rate bounds on the goodness-of-fit test based on testing for typicality with respect to the base distribution • We prove theorems stating that the typical sets of any two distributions having sufficiently high KL divergence must have low intersection , and that distributions having low KL divergence must have non-zero intersection . • We use these theorems to motivate our proposed method for conservative goodness-of-fit testing . Specifically , we propose training an ensemble of models , and show that by taking the intersection of their typical sets , we can approximately recover the typical set of the ground truth distribution . We show that such an ensemble can exist and give sufficient conditions for its existence . • We demonstrate on synthetic data sets that the typical set of standard learned distributions and the ground-truth distribution often have low intersection , even when the class of densities from which we approximate the ground truth contains the ground-truth . We validate that our proposed method addresses this issue . 2 PRELIMINARIES . The setting we are concerned with is the following . Consider a continuous random variable x ∈ X with probability density function p ( x ) . Let xn : = ( x1 , x2 , ... , xn ) denote the collection of n random variables x . Let hp denote the differential entropy of p ( x ) . For > 0 and positive integer n , The typical set with respect to p ( x ) is defined as the following : T ( n ) : = { xn ∈ Xn : | − 1 n log p ( xn ) − hp| < } . ( 1 ) In words , this is the set of sequences of samples whose average negative-log-probability is close to the differential entropy . This set has high probability under p ( x ) , implying that most sequences of data points sampled from p ( x ) are contained in this set ( Cover & Thomas , 2012 ) . 2.1 HYPOTHESIS TESTING . We are interested in determining the plausibility that some collection of samples x̃n ∈ Xn were sampled i.i.d . according to p ( x ) . In hypothesis testing terminology , we are interested in determining which of two hypotheses are more probable : • The null-hypothesis , H0 : = x̃n ∼ p ( x ) • The alternative-hypothesis , H1 : = x̃n ∼ p̂ ( x ) , where here p̂ ( x ) is any distribution such that DKL ( p‖p̂ ) ≥ d. If we define An ⊂ Xn to be the acceptance region for the null-hypothesis , or the set of all sequences xn such that H0 is deemed more probable , then we can define the probabilities of error as the following : αn = p n ( Acn ) , βn = max p̃ : D ( p‖p̃ ) ≥d p̃n ( An ) . ( 2 ) Typically we desire tests that minimize βn for a fixed αn , or tests that minimize some linear combination of the two . The authors in Nalisnick et al . ( 2019 ) propose a test procedure which accepts the null-hypothesis iff x̃n ∈ T ( n ) . In other words , a collection of points are determined to be anomalous with respect to p ( x ) iff x̃n 6∈ T ( n ) . In that work , they show that this test performs about as well as other tests such as the Student ’ s t-test , the Kolmogorov-Smirnov test , the Maximum Mean Discrepancy test , and the Kernelized Stein Discrepancy test . We note that in those comparisons , all tests are performed with respect to a learned density as a proxy for the ground-truth density . In this work , we consider the same typicality-based test for accepting or rejecting the null hypothesis . We focus on this test since it allows for analysis into what happens when the proxy learned density for which the typical set is constructed is different from the ground-truth distribution p ( x ) . In order to validate this approach , we first prove that for a fixed αn , the typical set test achieves an error rate βn that is at worst , given by : Theorem 1 . Let the region of acceptance for the typicality test be defined by the set T ( n ) ( p ( x ) ) . For n sufficiently large , then αn < , and βn < max p̃ : D ( p‖p̃ ) ≥d e−n ( DKL ( p̃‖p ) +hp̃−hp−3 ) + 3 Proof of Theorem 1 . See Section A.1 . This theorem states that for a fixed rate of correctly accepting H0 , the test for typicality will fail to detect anomalous data at a rate no greater than the bound given . 2.2 DENSITY LEARNING AS OPTIMIZATION . In order to perform the test on typicality to determine whether a sequence of data points are anomalous or not , a model of the probability density function p ( x ) is needed . For many practical applications , we are only ever presented with a data set of N samples from p ( x ) , which we denote X̄ = ( x̄1 , x̄2 , ... x̄N ) . However , an estimate of the ground-truth density can be learned . We denote a parameterized distribution by q ( x ; θ ) , which can be learned by minimizing the following objective : min θ DKL ( p ( x ) ‖q ( x ; θ ) ) . ( 3 ) The KL divergence is defined by DKL ( p ( x ) ‖q ( x ; θ ) ) : = Ep [ log p ( x ) q ( x ; θ ) ] . By expanding terms and eliminating constants , it is clear that an equivalent optimization problem is max θ Ep [ log q ( x ; θ ) ] ≈ max θ 1 N N∑ i=1 log q ( x̄i ; θ ) . ( 4 ) The optimal θ in this problem is that which maximizes the log likelihood on the data set X̄ . This is why this optimization is commonly referred to as maximum-likelihood estimation . Importantly , the dependence on the unknown true distribution p ( x ) was removed through the use of the law of large numbers . Since the KL-divergence is equal to zero if and only if p ( x ) = q ( x ; θ ) ∀x ∈ X , this objective is well-motivated if we wish that q ( x ; θ ) ≈ p ( x ) . However , there are many other statistical divergences between distributions that would also be suitable as objectives in the optimizations above . In fact , many of these other divergences might be preferred , especially in the context of anomaly detection . Among other reasons , this is because when the parameterized class of distributions q ( x ; θ ) is highly expressive , the optimizations are non-convex , and local optima may be found with sub-optimal properties . This can be true even if there exist some θ∗ such that q ( x ; θ∗ ) = p ( x ) . For example , by looking at the form of the KL-divergence , there is no direct penalty for q ( x ; θ ) in assigning a high density to points far away from any of the x̄i ’ s . This can lead to locally optimal learned densities which have high probability density in regions of X that p ( x ) does not . This can potentially lead to situations in which a collection of points can be anomalous with respect to p ( x ) , but in-distribution with respect to the sub-optimally learned q ( x ; θ ) . There exist other divergences which do not suffer this effect , but it is not obvious how to optimize with respect to them . For example , the reverse KL-divergence , which switches the places of p ( x ) and q ( x ; θ ) in the standard KL-divergence , has an alternate effect ; q ( x ; θ ) is directly penalized for assigning high density to anywhere that does not also have high density under p ( x ) . Unfortunately , this requires direct knowledge of p ( x ) to evaluate the objective , as do all divergences other than the forward KL , to the best of our knowledge . This makes the forward KL-divergence special in that it is the only divergence which can directly be optimized for . These implications are important when considering how learning a density affects the hypothesis testing problem .

Summary: This paper analyzes and extends a recently proposed goodness-of-fit test based on typicality [Nalisnick et al., ArXiv 2019].  Firstly, the authors give bounds on the type-II error of this test, showing it can be characterized as a function of KLD[q || p_true] where p is the true data generating process and q is an alternative generative process.  The paper then shifts to the main contribution: an in-depth study of a Gaussian mixture simulation along with accompanying theoretical results.  The simulation shows that maximum likelihood estimation (MLE)---due to it optimizing KLD[p_true || p_model]---does not penalize the model for placing probability in places not occupied by p_true.  This means that while samples from p_true should fall within the model’s typical set, the model typical set may be broader than p_true’s.  Table 1 makes this clear by showing that only 30-40% of samples from the model fall within the typical set of p_true.  Yet >93% of samples from p_true fall within the models’ typical sets.  The paper then makes the observation that the models do not have high overlap in their typical sets, and thus p_true’s typical set could be well approximated by the intersection of the various models’ typical sets.  Applying this procedure to the Gaussian mixture simulation, the authors observe that ~95% of samples drawn from the intersection of the ensemble fall within p_true’s typical set.  Moreover, ~97% of samples from p_true are in the ensemble (intersection) typical set.  The paper closes by proving that the diversity of the ensemble controls the overlap in their typical sets, and hence increasing diversity should only improve the approximation of p_true’s typical set.