Interpretable Distribution Features with Maximum Testing Power
Wittawat Jitkrittum, Zoltan Szabo, Kacper Chwialkowski, Arthur Gretton
Introduction
We address the problem of discovering features of distinct probability distributions, with which they can most easily be distinguished. The distributions may be in high dimensions, can differ in non-trivial ways (i.e., not simply in their means), and are observed only through i.i.d. samples. One application for such divergence measures is to model criticism, where samples from a trained model are compared with a validation sample: in the univariate case, through the KL divergence (Cinzia Carota and Polson, 1996), or in the multivariate case, by use of the maximum mean discrepancy (MMD) (Lloyd and Ghahramani, 2015). An alternative, interpretable analysis of a multivariate difference in distributions may be obtained by projecting onto a discriminative direction, such that the Wasserstein distance on this projection is maximized (Mueller and Jaakkola, 2015). Note that both recent works require low dimensionality, either explicitly (in the case of Lloyd and Gharamani, the function becomes difficult to plot in more than two dimensions), or implicitly in the case of Mueller and Jaakkola, in that a large difference in distributions must occur in projection along a particular one-dimensional axis. Distances between distributions in high dimensions may be more subtle, however, and it is of interest to find interpretable, distinguishing features of these distributions.
Our approach builds on the analytic representations of probability distributions of Chwialkowski et al. (2015), where differences in expectations of analytic functions at particular spatial or frequency locations are used to construct a two-sample test statistic, which can be computed in linear time. Despite the differences in these analytic functions being evaluated at random locations, the analytic tests have greater power than linear time tests based on subsampled estimates of the MMD (Gretton et al., 2012b; Zaremba et al., 2013). Our first theoretical contribution, in Sec. 3, is to derive a lower bound on the test power, which can be maximized over the choice of test locations. We propose two novel tests, both of which significantly outperform the random feature choice of Chwialkowski et al.. The (ME) test evaluates the difference of mean embeddings at locations chosen to maximize the test power lower bound (i.e., spatial features); unlike the maxima of the MMD witness function, these features are directly chosen to maximize the distinguishability of the distributions, and take variance into account. The Smooth Characteristic Function (SCF) test uses as its statistic the difference of the two smoothed empirical characteristic functions, evaluated at points in the frequency domain so as to maximize the same criterion (i.e., frequency features). Optimization of the mean embedding kernels/frequency smoothing functions themselves is achieved on a held-out data set with the same consistent objective.
As our second theoretical contribution in Sec. 3, we prove that the empirical estimate of the test power criterion asymptotically converges to its population quantity uniformly over the class of Gaussian kernels. Two important consequences follow: first, in testing, we obtain a more powerful test with fewer features. Second, we obtain a parsimonious and interpretable set of features that best distinguish the probability distributions. In Sec. 4, we provide experiments demonstrating that the proposed linear-time tests greatly outperform all previous linear time tests, and achieve performance that compares to or exceeds the more expensive quadratic-time MMD test (Gretton et al., 2012a). Moreover, the new tests discover features of text data (NIPS proceedings) and image data (distinct facial expressions) which have a clear human interpretation, thus validating our feature elicitation procedure in these challenging high-dimensional testing scenarios.
ME and SCF tests
One can intuitively think of the ME test statistic as a squared normalized (by the inverse covariance ) distance of the mean embeddings (Smola et al., 2007) of the empirical measures , and where , and is the Dirac measure concentrated at . The unnormalized counterpart (i.e., without ) was shown by Chwialkowski et al. (2015) to be a metric on the space of probability measures for any . Both variants behave similarly for two-sample testing, with the normalized version being a semimetric having a more computationally tractable null distribution, i.e., .
In this work, we modify the statistic with a regularization parameter , giving , for stability of the matrix inverse. Using multivariate Slutsky’s theorem, under , still asymptotically follows provided that as .
Lower bound on test power, consistency of empirical power statistic
Proposition 1 suggests that for large it is sufficient to maximize to maximize a lower bound on the ME test power. The same conclusion holds for the SCF test (result omitted due to space constraints). Assume that is characteristic (Sriperumbudur et al., 2011). It can be shown that if and only if i.e., is a semimetric for and . In this sense, one can see as encoding the ease of rejecting . The higher , the easier for the test to correctly reject when holds. This observation justifies the use of as a maximization objective for parameter tuning.
Contributions The statistic for both ME and SCF tests depends on a set of test locations and a kernel parameter . We propose to set . The optimization of brings two benefits: first, it significantly increases the probability of rejecting when holds; second, the learned test locations act as discriminative features allowing an interpretation of how the two distributions differ. We note that optimizing parameters by maximizing a test power proxy (Gretton et al., 2012b) is valid under both and as long as the data used for parameter tuning and for testing are disjoint. If holds, then is arbitrary. Since the test statistic asymptotically follows for any , the optimization does not change the null distribution. Also, the rejection threshold depends on only and is independent of .
To avoid creating a dependency between and the data used for testing (which would affect the null distribution), we split the data into two disjoint sets. Let and such that and . In practice, since and are unknown, we use in place of , where is the test statistic computed on the training set . For simplicity, we assume that each of and has half of the samples in . We perform an optimization of with gradient ascent algorithm on . The actual two-sample test is performed using the test statistic computed on . The full procedure from tuning the parameters to the actual two-sample test is summarized in Sec. A.
for and .
The idea is to lower bound the difference with an expression involving and . These two quantities can be seen as suprema of empirical processes, and can be bounded by Rademacher complexities of their respective function classes (i.e., and ). Finally, the Rademacher complexities can be upper bounded using Dudley entropy bound and VC subgraph properties of the function classes. Proof details are given in Sec. D. ∎
Experiments
In this section, we demonstrate the effectiveness of the proposed methods on both toy and real problems. We consider the isotropic Gaussian kernel class in all kernel-based tests. We study seven two-sample test algorithms. For the SCF test, we set . Denote by ME-full and SCF-full the ME and SCF tests whose test locations and the Gaussian width are fully optimized using gradient ascent on a separate training sample of the same size as the test set . ME-grid and SCF-grid are as in Chwialkowski et al. (2015) where only the Gaussian width is optimized by a grid search,Chwialkowski et al. (2015) chooses the Gaussian width that minimizes the median of the p-values, a heuristic that does not directly address test power. Here, we perform a grid search to choose the best Gaussian width by maximizing as done in ME-full and SCF-full.and the test locations are randomly drawn from a multivariate normal distribution. MMD-quad (quadratic-time) and MMD-lin (linear-time) refer to the nonparametric tests based on maximum mean discrepancy of Gretton et al. (2012a), where to ensure a fair comparison, the Gaussian kernel width is also chosen so as to maximize a criterion for the test power on training data, following the same principle as (Gretton et al., 2012b). For MMD-quad, since its null distribution is given by an infinite sum of weighted chi-squared variables (no closed-form quantiles), in each trial we randomly permute the two samples 400 times to approximate the null distribution. Finally, is the standard two-sample Hotelling’s T-squared test, which serves as a baseline with Gaussian assumptions on and .
Optimization The parameter tuning objective is a function of consisting of one real-valued and test locations each of dimensions. The parameters can thus be regarded as a Euclidean vector. We take the derivative of with respect to , and use gradient ascent to maximize it. is pre-specified and fixed. For the ME test, we initialize the test locations with realizations from two multivariate normal distributions fitted to samples from and ; this ensures that the initial locations are well supported by the data. For the SCF test, initialization using the standard normal distribution is found to be sufficient. The parameter is not optimized; we set the regularization parameter to be as small as possible while being large enough to ensure that can be stably computed. We emphasize that both the optimization and testing are linear in . The testing cost and the optimization costs per gradient ascent iteration. Runtimes of all methods are reported in Sec. C in the appendix.
We begin with a demonstration that the proxy for the test power is informative for revealing the difference of the two samples in the ME test. We consider the Gaussian Mean Difference (GMD) problem (see Table 1), where both and are two-dimensional normal distributions with the difference in means. We use test locations and , where is fixed to the location indicated by the black triangle in Fig. 1. The contour plot shows .
Fig. 1 (top) suggests that is maximized when is placed in either of the two regions that captures the difference of the two samples i.e., the region in which the probability masses of and have less overlap. Fig. 1 (bottom), we consider placing in one of the two key regions. In this case, the contour plot shows that should be placed in the other region to maximize , implying that placing multiple test locations in the same neighborhood will not increase the discriminability. The two modes on the left and right suggest two ways to place the test location in a region that reveals the difference. The non-convexity of the is an indication of many informative ways to detect differences of and , rather than a drawback. A convex objective would not capture this multimodality.
The results are shown in Fig. 2 where type-I error (for SG problem), and test power (for GMD, GVD and Blobs problems) are plotted against test sample size. A number of observations are worth noting. In the SG problem, we see that the type-I error roughly stays at the specified level: the rate of rejection of when it is true is roughly at the specified level .
GMD with 100 dimensions turns out to be an easy problem for all the tests except MMD-lin. In the GVD and Blobs cases, ME-full and SCF-full achieve substantially higher test power than ME-grid and SCF-grid, respectively, suggesting a clear advantage from optimizing the test locations. Remarkably, ME-full consistently outperforms the quadratic-time MMD across all test sample sizes in the GVD case. When the difference of and is subtle as in the Blobs problem, ME-grid, which uses randomly drawn test locations, can perform poorly (see Fig. 2d) since it is unlikely that randomly drawn locations will be placed in the key regions that reveal the difference. In this case, optimization of the test locations can considerably boost the test power (see ME-full in Fig. 2d). Note also that SCF variants perform significantly better than ME variants on the Blobs problem, as the difference in and is localized in the frequency domain; ME-full and ME-grid would require many more test locations in the spatial domain to match the test powers of the SCF variants. For the same reason, SCF-full does much better than the quadratic-time MMD across most sample sizes, as the latter represents a weighted distance between characteristic functions integrated across the entire frequency domain (Sriperumbudur et al., 2010, Corollary 4).
We next investigate how the dimension () of the problem can affect type-I errors and test powers of ME and SCF tests. We consider the same artificial problems: SG, GMD and GVD. This time, we fix the test sample size to 10000, set , and vary the dimension. The results are shown in Fig. 3. Due to the large dimensions and sample size, it is computationally infeasible to run MMD-quad.
We observe that all the tests except the T-test can maintain type-I error at roughly the specified significance level as dimension increases. The type-I performance of the T-test is incorrect at large because of the difficulty in accurately estimating the covariance matrix in high dimensions. It is interesting to note the high performance of ME-full in the GMD problem in Fig. 3b. ME-full achieves the maximum test power of 1.0 throughout and matches the power T-test, in spite of being nonparametric and making no assumption on and (the T-test is further advantaged by its excessive Type-I error). However, this is true only with optimization of the test locations. This is reflected in the test power of ME-grid in Fig. 3b which drops monotonically as dimension increases, highlighting the importance of test location optimization. The performance of MMD-lin degrades quickly with increasing dimension, as expected from Ramdas et al. (2015).
Type-I errors and test powers are summarized in Table. 2. The first column indicates the categories of the papers in the two samples. In Bayes-Bayes problem, papers on Bayesian inference are randomly partitioned into two samples in each trial. This task represents a case in which holds. Among all the linear-time tests, we observe that ME-full has the highest test power in all the tasks, attaining a maximum test power of 1.0 in the Bayes-Neuro problem. This high performance assures that although different test locations may be selected in different trials, these locations are each informative. It is interesting to observe that ME-full has performance close to or better than MMD-quad, which requires runtime complexity. Besides clear advantages of interpretability and linear runtime of the proposed tests, these results suggest that evaluating the differences in expectations of analytic functions at particular locations can yield an equally powerful test at a much lower cost, as opposed to computing the RKHS norm of the witness function as done in MMD. Unlike Blobs, however, Fourier features are less powerful in this setting.
In the final experiment, we study how well ME and SCF tests can distinguish two samples of photos of people showing positive and negative facial expressions. Our emphasis is on the discriminative features of the faces identified by ME test showing how the two groups differ. For this purpose, we use Karolinska Directed Emotional Faces (KDEF) dataset (Lundqvist et al., 1998) containing 5040 aligned face images of 70 amateur actors, 35 females and 35 males. We use only photos showing front views of the faces. In the dataset, each actor displays seven expressions: happy (HA), neutral (NE), surprised (SU), sad (SA), afraid (AF), angry (AN), and disgusted (DI). We assign HA, NE, and SU faces into the positive emotion group (i.e., samples from ), and AF, AN and DI faces into the negative emotion group (samples from ). We denote this problem as “ vs. ”. Examples of six facial expressions from one actor are shown in Fig. 4. Photos of the SA group are unused to keep the sizes of the two samples the same. Each image of size pixels is cropped to exclude the background, resized to pixels (), and converted to grayscale.
We run the tests 500 times with the same setting used previously i.e., Gaussian kernels, and . The type-I errors and test powers are shown in Table 3. In the table, “ vs. ” is a problem in which all faces expressing the six emotions are randomly split into two samples of equal sizes i.e., is true. Both ME-full and SCF-full achieve high test powers while maintaining the correct type-I errors.
As a way to interpret how positive and negative emotions differ, we take an average across trials of the learned test locations of ME-full in the “ vs. ” problem. This average is shown in Fig. 4g. We see that the test locations faithfully capture the difference of positive and negative emotions by giving more weights to the regions of nose, upper lip, and nasolabial folds (smile lines), confirming the interpretability of the test in a high-dimensional setting.
Acknowledgement
We thank the Gatsby Charitable Foundation for the financial support.
References
Appendix A Algorithm
The full algorithm for the proposed tests from parameter tuning to the actual two-sample testing is given in Algorithm 1.
Appendix B Experiments on NIPS text collection
The full procedure for processing the NIPS text collection is summarized as following.
Download all 5903 papers from 1988 to 2015 from https://papers.nips.cc/ as PDF files.
Convert each PDF file to text with pdftotextpdftotext is available at http://poppler.freedesktop.org..
Remove all stop words. We use the list of stop words from http://www.ranks.nl/stopwords.
Keep only nouns. We use the list of nouns as available in WordNet-3.0WordNet is available online at https://wordnet.princeton.edu/wordnet/citing-wordnet/..
Keep only words which contain only English alphabets i.e., does not contain punctuations or numbers. Also, word length must be between 3 and 20 characters (inclusive).
Keep only words which occur in at least 5 documents, and in no more than 2000 documents.
Convert all characters to small case. Stem all words with SnowballStemmer in NLTK (Bird et al., 2009). For example, “recognize” and “recognizer” become “recogn” after stemming.
Categorize papers into disjoint collections. A paper is treated as belonging to a group if its title has at least one word from the list of keywords for the category. Papers that match the criteria of both categories are not considered. The lists of keywords are as follows.
Bayesian inference (Bayes): graphical model, bayesian, inference, mcmc, monte carlo, posterior, prior, variational, markov, latent, probabilistic, exponential family.
Deep learning (Deep): deep, drop out, auto-encod, convolutional, neural net, belief net, boltzmann.
Learning theory (Learn): learning theory, consistency, theoretical guarantee, complexity, pac-bayes, pac-learning, generalization, uniform converg, bound, deviation, inequality, risk min, minimax, structural risk, VC, rademacher, asymptotic.
Neuroscience (Neuro): motor control, neural, neuron, spiking, spike, cortex, plasticity, neural decod, neural encod, brain imag, biolog, perception, cognitive, emotion, synap, neural population, cortical, firing rate, firing-rate, sensor.
Randomly select 2000 words from the remaining words.
Treat each paper as a bag of words and construct a feature vector with TF-IDF (Manning et al., 2008).
In this section, we provide full lists of discriminative terms following the procedure described in Sec. 4. The top ten words in each problem are as follows.
Bayes-Bayes: collabor, traffic, bay, permut, net, central, occlus, mask, draw, joint.
Bayes-Deep: infer, bay, mont, adaptor, motif, haplotyp, ecg, covari, boltzmann, classifi.
Bayes-Learn: infer, markov, graphic, segment, bandit, boundari, favor, carlo, prioriti, prop.
Bayes-Neuro: spike, markov, cortex, dropout, recurr, iii, gibb, basin, circuit, subsystem.
Learn-Deep: deep, forward, delay, subgroup, bandit, recept, invari, overlap, inequ, pia.
Learn-Neuro: polici, interconnect, hardwar, decay, histolog, edg, period, basin, inject, human.
Appendix C Runtimes
In this section, we provide runtimes of all the experiments. The runtimes of the “Test power vs. sample ” experiment are shown in Fig. 5. The runtimes of the “Test power vs. dimension ” experiment are shown in Fig. 6. Table 4, 5 give the runtimes of the two real-data experiments.
In the cases where is large (Fig. 5), MMD-quad has the largest runtime due to its quadratic dependency on the sample size. In the extreme case where the test sample size is (Fig. 6), it is computationally infeasible to run MMD-quad. We observe that the proposed ME-full and SCF-full have a slight overhead from the parameter optimization. However, since the optimization procedure is also linear in , we are able to conduct an accurate test in less than 10 minutes even when the test sample size is 10000 and (see Fig. 6a, 6b). We note that the actual tests (after optimization) for all ME and SCF variants take less than one second in all cases. In the ME-full, we initialize the test locations with realizations from two multivariate normal distributions fitted to samples from and . When is large, this heuristic can be expensive. An alternative initialization scheme for is to randomly select points from the two samples.
Appendix D Proof of theorem 2
Let be a collection of subsets of (). is said to shatter an set, if for any there exist such that ; in other words, arbitrary subset of can be cut out by an element of . The VC index of is the smallest for which no set of size i is shattered:
For brevity, we will interchangeably use for and for . and will be used mainly when the dependency of needs to be emphasized. We start with and upper bound the argument of as
where at (a) we use and at (b) we use .
Combining the upper bounds for and , we arrive at
using that . Let us bound the argument of the supremum:
by the triangle inequality and exploiting that with . Thus, we have
using the triangle inequality, the sub-additivity of , , , [see Eq. (5)] and
with Eq. (6). Considering the first term in Eq. (8)
by exploiting that , and with . Using the bounds obtained for the two terms of Eq. (8), we get
D.5 Bounding by concentration and the VC property
Applying Lemma 3 with , we get the statement with a union bound.
a uniformly bounded () separable Carathéodory family.
where the universal constant is associated according to Lemma 7(iv).
Hence, applying Lemma 8, and using symmetrization Steinwart and Christmann (2008) (Prop. 7.10) for the uniformly bounded separable Carathéodory class, for arbitrary with probability at least
Uniform boundedness of -s [see Eqs. (1)-(2)]: If is uniformly bounded, i.e., such that ; then , and [Eqs. (1)-(2)] are also uniformly bounded with , , constants, respectively. That is, , , .
Separability of : since , and is parameterized by , , , separability of implies that of .
Measurability of : is measurable, then the elements of () are also measurable.
Appendix E Example kernel families
Below we give examples for kernel classes for which the associated -s are VC-subgraph and uniformly bounded separable Carathéodory families. The VC property will be a direct consequence of the VC indices of finite-dimensional function classes and preservation theorems (see Lemma 7); for a nice example application see Srebro and Ben-David (2006) (Section 5) who study the pseudo-dimension of kernel classes, for different Gaussian families. We take these Gaussian classes (isotropic, full) and use the preservation trick to bound the VC indices of the associated -s.
VC-subgraphs with indices , , , and
uniformly bounded separable Carathéodory families, with for all . for and , and in case of .
: Since , and , .
from the result on we get that .
VC-subgraphs with indices , , ,
uniformly bounded separable Carathéodory families, with for all .4
We prove the VC index values; the rest is essentially identical to the proof of Lemma 5.
: Using that , we have .
: Since , and
we have .
and , we have .
Appendix F Proof of proposition 1
We will bound each of the three terms in (12).
where we used the fact that . It can be seen that because
We can upper bound by applying Hoeffding’s inequality to bound giving
Applying a union bound on (13), (14), and (16) with , we can conclude that
Define . We have
Appendix G External lemmas
In this section we detail some external lemmas used in our proof.
Finite-dimensional vector space: if is a finite-dimensional vector space of measurable functions, then .
for any with a universal constant .
bounded difference property holds. Then for arbitrary
Equivalently, for any , with probability at least , it holds that