{'fraction_non_alphanumeric': 0.03999632892804699, 'fraction_numerical': 0.00961820851688693, 'mean_word_length': 4.2623394185260315, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On the Definiteness of Earth Mover's Distance and Its Relation to Set Intersection

Positive definite kernels are an important tool in machine learning that enable efficient solutions to otherwise difficult or intractable problems by implicitly linearizing the problem geometry. In this paper we develop a set-theoretic interpretation of the Earth Mover's Distance (EMD) and propose Earth Mover's Intersection (EMI), a positive definite analog to EMD for sets of different sizes. We provide conditions under which EMD or certain approximations to EMD are negative definite. We also present a positive-definite-preserving transformation that can be applied to any kernel and can also be used to derive positive definite EMD-based kernels and show that the Jaccard index is simply the result of this transformation. Finally, we evaluate kernels based on EMI and the proposed transformation versus EMD in various computer vision tasks and show that EMD is generally inferior even with indefinite kernel techniques.

Abstract-Positive definite kernels are an important tool in machine learning that enable efficient solutions to otherwise difficult or intractable problems by implicitly linearizing the problem geometry. In this paper we develop a set-theoretic interpretation of the Earth Mover's Distance (EMD) and propose Earth Mover's Intersection (EMI), a positive definite analog to EMD for sets of different sizes. We provide conditions under which EMD or certain approximations to EMD are negative definite. We also present a positive-definite-preserving transformation that can be applied to any kernel and can also be used to derive positive definite EMD-based kernels and show that the Jaccard index is simply the result of this transformation. Finally, we evaluate kernels based on EMI and the proposed transformation versus EMD in various computer vision tasks and show that EMD is generally inferior even with indefinite kernel techniques.

I. INTRODUCTION
T HE foundations of the earth mover's distance (EMD)'s definiteness are the primary topic of this paper. EMD is a metric that measures the minimum amount of one histogram that must be altered to transform it into another. EMD is commonly used in computer vision for comparing color distribution or texture histograms of images for content based image retrieval [1]- [5]. If each histogram is represented by piles of dirt, EMD is the minimum cost required to move the dirt of one histogram until it acquires the distribution of the other, and from this interpretation its name-first used in print by Rubner et al. [2]-naturally follows. EMD, however, has a much longer history than its use in computer vision would imply. Gaspard Monge [6] originally laid the groundwork for EMD, and the problem was reformulated in the mid-20th century by Leonid Kantorovich [7], [8]. Thus does EMD receive its other name, the Monge-Kantorovich mass transportation distance, under which it is applied in economics, fluid mechanics, meteorology, and partial differential equations (PDEs) [9], [10]. In statistics, EMD is also known as the Wasserstein or Mallows distance between probability distributions [11], [12]. The Wasserstein distance is also used as a means of evaluating the performance of multiple-object trackers and filters [13]- [15]. For a more comprehensive description of its history, the reader is referred to Vershik's recent article on the subject [16]. EMD is normally understood to be a discretized version of the Monge-Kantorovich distance, which is defined for continuous measures. Regardless of the context, we will henceforth use EMD to refer to this distance in all of its various forms.
The ground distance refers to the cost function chosen to define the distance between histogram bins. EMD is usually assumed to possess a Euclidean ground distance, but examples of other ground distances exist in the literature. Igbida et al. [17] study EMD in the context of PDEs with a discretized version of the Euclidean ground distance rounded up to the nearest whole number. Ling and Okada [3] proposed an efficient tree-based algorithm for computing EMD with a Manhattan ground distance, and Pele and Werman [5] explored the effect of applying a threshold to various ground distances and its impact on computation time and accuracy. In the realm of image retrieval, EMD is often applied as a metric for nearest neighbor searches.
EMD has also been applied in kernel methods for texture and object category classification with support vector machines (SVMs) [18]. A kernel is a function that possesses certain properties, namely symmetry and positive definite (PD)-ness, that can be used to efficiently solve certain nonlinear problems as though they are linear. However, it is not known whether kernels derived from EMD are actually PD. In fact, there is evidence to the contrary for a Euclidean ground distance [19]. Regardless, EMD continues to be used successfully for various purposes such as facial expression analysis [20] and EEG classification [21]. Methods to ensure PD-ness have been explored [22]. Cuturi [23] suggested using the permanent of the transportation polytope, which is guaranteed to be PD although difficult to compute. Grauman and Darrell [24] on the other hand proposed a PD approximation of a maximumcost version of EMD that also has the advantage of being easier to compute.

A. Our Contributions
In this paper we provide the following contributions: • In Section III, we prove that the transformation (9) is PD-preserving and generalizes the Tanimoto kernel of Ralaivola et al. [25]. Coincidentally, we provide a new independent proof of the Jaccard index's PD-ness, which has already been the subject of at least two papers [26], [27]. As a corollary, we also deduce that the biotope transform [28] preserves conditionally negative definite (CND)-ness in addition to metric properties.
• In Section IV, we propose earth mover's intersection, a generalization of Pele and Werman's EMD [4] for kernels based on EMD with unnormalized sets. We show that given certain ground distances, EMD is CND and may thus be used to construct PD kernels using standard relations (e.g. Lemma 1). • We evaluate EMD and its transformation using (9) in a variety of classification experiments and show that both yield kernels superior to EMD, especially on unnormalized sets. The transformation in particular is shown to have some numerical advantages. The next section presents relevant background material that may be used as a reference for the rest of the paper.

II. PRELIMINARIES
This section provides definitions, lemmas, and other material that are useful for following the rest of the paper.

A. Metrics
A metric on a set X is defined as follows. DEFINITION 1. A function δ : X × X → R is a metric if and only if the following properties are satisfied for every x, y, z ∈ X.
As can be inferred from its name, the discrete metric is a metric. We also define the term semimetric to indicate satisfaction of all of the preceding properties except for the triangle inequality. The Euclidean distance is a metric, and the squared Euclidean distance is a semimetric. A simple example of the squared Euclidean distance failing the triangle inequality may be noted with the points x = (0, 0), y = (0, 2), and z = (0, 1) as elements of R 2 . We use the term discrete metric to refer to the 0-1 distance defined by δ 0-1 (x, y) = 0 if x = y and 1 otherwise.

B. Kernels
A kernel on a set X is, in general, a function K : X ×X → R.

DEFINITION 2.
A kernel K is PD if and only if it is symmetric and for any choice of n distinct elements x 1 , . . . , x n and real numbers c 1 , . . . , c n , n i,j=1 If the constraint n i=1 c i = 0 is added, then K is conditionally positive definite (CPD).
The condition (1) is equivalent to testing whether the kernel matrix for the chosen elements G K = [K(x i , x j )] is positive semi-definite via a quadratic form, i.e. c G K c ≥ 0 where c = c 1 , . . . , c n . A (conditionally) strictly PD kernel is one in which the preceding inequalities are strict with equality holding only if each c i = 0. One may note that PD implies CPD, but the converse does not hold. Simply reversing the inequality of (1) yields negative definite (ND) kernels of each respective type. Consequently, if K is PD, then −K is ND. Note that we follow traditional nomenclature for kernels in that PD and strictly PD kernels correspond to positive semidefinite and PD matrices, respectively. PD kernels are useful for a variety of machine learning tasks including classification, regression, and principal component analysis.
PD-ness is attractive because it implies the existence of a mapping φ : X → H from X to some Hilbert space H in which the kernel gives the value of the inner product and certain nonlinear problems in X become linear [29], [30], i.e.
This property is the key component of the so-called "kernel trick" for SVMs, wherein a separating hyperplane is implicitly found without ever working directly in H. A CND kernel is also related to some Hilbert space H via a mapping φ by The existence of φ implies the respective type of definiteness and vice versa. CND kernels are sometimes referred to as metrics of negative type, and as indicated by (2), correspond to functions that isometrically embed into squared Euclidean space.
The following three results are adapted from Berg et al. [31] and form a basis for several later propositions. Theorem 1 and Lemma 1 propose relationships between CND and PD kernels. The standard kernel used with EMD relies upon Theorem 1 with u < 0 and K equal to EMD presumed to be CND. Theorem 2, originally proved by Schur [32], demonstrates that PD kernels are closed under multiplication. Note that Theorem 2 does not apply to CPD kernels. Theorem 1 ( [31]). Let X be a nonempty set and let K : X × X → R be a symmetric kernel. Then K is CND (CPD) if and only if exp(uK) is PD for each u < 0 (0 < u).
The next two propositions are adapted from Boughorbel et al. [33] and were involved in the derivation of the generalized histogram intersection kernel. As a preview of upcoming proofs and an example of working with kernels, a proof of Proposition 1 is given.
is both a CPD and CND kernel for any function f .

C. Measures and Multisets
A measure is a function that generalizes the notion of cardinality, area, volume, or length. To be precise, a measure µ : Σ X → R assigns a number to subsets contained in a σalgebra Σ X of some set X. The measure of a subset must be less than or equal to that of its superset, i.e. µ( Measures also possess countable additivity, i.e. the measure of the union of disjoint sets is the sum of their measures. For the remainder of the paper, we assume that sets are non-negative and finitely measurable. A measure space (X, Σ, µ) is a measurable space (X, Σ) paired with a measure µ. Cardinality is sometimes referred to as the counting or discrete measure. We will use the terms mass, size, and measure interchangeably to denote the value of µ(A).
A multiset generalizes a set by allowing duplicate elements. We use the terms multiset and set interchangeably with context indicating which is meant in the strict sense. By definition, the multiplicity of an element x is a non-negative integer indicating how many copies of x are contained in a given multiset. We generalize this definition by allowing a nonnegative real number of "copies." With this definition, we may also include probability distributions and other continuous functions with real output.
Let X be the set of all possible elements under consideration. Let χ A (x) be the mass density (or multiplicity) function of the multiset A ⊆ X with x ∈ X. The density function completely defines a multiset. When we refer to one, the other is implied. Note that for a standard set A (i.e. not multiset), χ A (x) is the characteristic or indicator function of A returning 1 for x ∈ A. For any element x not contained in A, χ A (x) = 0. The mass density function of A gives rise to a measure For discrete sets, (3) simplifies to series summation. The membership of an element x ∈ A is contingent upon χ A (x) > 0, and the support of a multiset supp(A) is the set of all elements x ∈ X for which χ A (x) = 0. We use the term singleton to denote a multiset A with support satisfying supp(A) = {x 0 } for some fixed element x 0 ∈ A. We generalize the definition of a subset A ⊆ B in X to be such that χ A (x) ≤ χ B (x) for each x ∈ X. The density function for the intersection of two multisets A and B is defined as and the union is similarly defined with max instead of min: We also define the sum of two sets as Define F(X) to be the family of multisets A with support supp(A) ⊂ X yielding finite, non-negative measure µ A (X), and let P(X) ⊂ F(X) be the family of all multisets A with µ A (X) = 1 (i.e. probability distributions). Henceforth, we will abuse notation by defining µ(A) = µ A (supp(A)). Unlike histograms, multisets do not imply a finite, countable base set X from which every set draws its support. This distinction allows somewhat more flexible definitions of EMD.

D. Earth Mover's Distance
We consider EMD to be a metric 2 on F(X) for some set X. Application of EMD requires specification of a ground distance D : X × X → R and computation of the flow f (a, b) of mass from a ∈ A to b ∈ B with A, B ∈ F(X). Since any ground distance is just a special case of EMD between singletons of unit mass, EMD is CND only if the ground distance is CND. Unless otherwise noted, we will assume that any ground distances discussed henceforth are CND. EMD may then be defined as the solution of the following linear programming problem, which calculates the cost of the minimum-cost maximum flow: subject to the constraints a∈A b∈B For convenience, we have defined EMD with the assumption that A and B both have discrete support. Constraints (6) and (7) state that the amount of each element transported is limited by the available mass in each set located at that element. By similar reasoning, note that the sum of the overall flow is 2 Here we mean metric as in dissimilarity measure. Note that EMD is not a true metric in the sense of Definition 1 on F (X) but rather on P(X) for metric ground distance [2]. Violations of identity and triangle inequality are easily found when considering subsets and supersets. constrained to be equal to the mass of the smaller set (8), effectively forcing the transportation of the maximum possible amount of mass. EMD has always been practically limited by the computational complexity involved in solving the linear program, although there has been recent development of fast approximation algorithms [34], [35].
Note that our definition of EMD differs slightly from that of Rubner et al. [2], which scales (5) by the inverse of the total flow in (8). For sets of the same size, Rubner's definition is just (5) scaled by a constant factor. Pele and Werman [4] introduced a means to calculate EMD between unnormalized histograms for use in nearest neighbor calculations and image retrieval: where α ≥ 0 and D is presumed to be bounded. EMD α is a metric on F(X) if EMD is a metric on P(X) and α ≥ 0.5 [4]. Schuhmacher et al. [14] independently proposed an almost identical version of EMD under the acronym OSPA (Optimal Subpattern Assignment).
Normalized forms of EMD have also been proposed by Gardner et al. [36] and by Ramon and Bruynooghe [37], although the latter did not acknowledge a connection to EMD. The transformation of the following section was inspired by the search for and study of a normalized form.

III. A DEFINITE-PRESERVING TRANSFORMATION
In this section we propose the PD-preserving transformation that normalizes any given PD kernel K. If K(x, x) = K(y, y) = 0, we define T [K] (x, y) = 1. As opposed to the traditional normalization, which can be interpreted as a surjective mapping of images φ(x) in Hilbert space onto the unit hypersphere via projection, can be interpreted as an injective mapping onto a unit hypersphere of unspecified dimension. Image vectors in Hilbert space of different magnitude that share the same direction remain distinguishable post-transformation. Technically, this kernel (or one algebraically equivalent to it) has been proposed before as the Tanimoto kernel by Ralaivola et al. [25]. We stress the differences in our proposed transformation and how our contributions differ from existing work. First, the Tanimoto kernel is equivalent to the Jaccard index and has only been proved PD when X consists solely of binary vectors and K is the dot product (see the proof given by Ralaivola et al., which hinges on the proof of semi-PDness of the Jaccard index given by Gower [26]). We prove (see Theorem 3) that (9) is strictly PD for any K if K is strictly PD (and similarly for semi-definiteness), which is stronger than the proof of Ralaivola et al. and more general than both it and the proof of strict PD-ness of the Jaccard index given by Bouchard et al. [27]. Since we are not limited to binary vectors, the range of (9) is not even constrained to be positive. This more general view of the transformation also allows us to examine its properties in new situations, such as when it is applied to itself or nested.
In fact, the transformation can be nested indefinitely as in for any x and K. Consequently, we note that for n ≥ 1, .
The following two propositions describe the limiting behavior of nested transformations. See Appendix A for proofs and a closed form expression of Proposition 3. For any PD kernel K, Proposition 4. For any symmetric kernel K : We now show that the transformation preserves definiteness as claimed.
Theorem 3. If K : X × X → R is PD, then the function T [K] as defined by (9) is also PD.
Proof. Without loss of generality, assume K(x, x) = K(y, y) = 0 =⇒ x = y = p for some p ∈ X and let us restrict K in the following discussion to X \ {p} . The denominator in (9) is positive valued due to a well-known property of PD kernels and matrices, The denominator is also CND as it is the sum of two CND kernels: K(x, x) + K(y, y) (by Proposition 1) and −K(x, y) (by hypothesis). Thus by Proposition 2 with γ = 1, is PD. We therefore have the product of two PD kernels which is itself PD by Theorem 2.
In order to include the case x = y = p, we note that if φ : X → H is the kernel's feature mapping into the Hilbert space H, then K(p, p) = φ(p), φ(p) = 0 =⇒ φ(p) = 0, which further implies Corollary 1. Let D : X × X → R be a CND kernel, and let p ∈ X. Then, is also CND.
Proof. We can define a PD kernel K p according to the relation given by Lemma 1, i.e.
Using (14), We see that the denominator of T p [D] is the same as that of T [K p ]. Note then that We have thus shown that T p [D] is CND.
. In addition, Theorem 3 also holds for strictly PD K. Using Theorem 3 with K as the intersection kernel therefore provides an easy proof for the PD-ness of the Jaccard index, Note that T p [D] generalizes the well-known biotope transform [28], showing that it preserves CND-ness in addition to metric properties. As an example, suppose A and B are sets and D(A, B) = |µ(A) − µ(B)|. This kernel is CND. By Corollary 1 with p = ∅ followed by some simplification, we can conclude that the following is CND:

IV. EARTH MOVER'S INTERSECTION: A SET THEORETIC INTERPRETATION OF EMD
In this section we introduce earth mover's intersection (EMI), a useful concept and PD analog to EMD that computes the similarity between two sets rather than their difference for a given ground distance. The name comes from the following motivating scenario.
Suppose there are two sets of two-dimensional points where one is a slightly perturbed version of the other. According to the strict definition of set intersection given by (4), their intersection is empty despite the fact that they are clearly related by their elements. The inability of set intersection to account for the sets' inherent similarity is a problem. EMD provides a natural solution to this problem, although it is proportional to the sets' difference rather than similarity. EMD also reflects the qualities of whatever norm is chosen to compare the individual points. We now show that EMD and subsequent related functions define smooth (in the sense of strictness of equality) generalizations or approximations of classic set operations.
Sets are usually normalized prior to application of EMD by dividing their density function by their total mass, an operation analagous to normalizing a vector to unit norm. The disadvantage of this method is that sets with differently scaled but otherwise identical density functions become indistinguishable post-normalization. As a side-effect, one removes an entire dimension of the data (for the most extreme case, consider singleton point sets with non-negative mass on the real line). An application where this distinction is important is that of multi-object tracking and filtering [14], [15]; normalizing set mass can cause one to ignore the fact that the incorrect number of objects are being tracked. For our set theoretic interpretation of EMD, we prefer to retain the sets' original mass and transport excess mass to a predetermined point p ∈ X. One could also consider this a form of additive normalization by supplementing mass at the point p. EMD then more accurately represents the relative magnitudes of set differences as well as distinguishes differently scaled sets.
Define the term EMD p to represent the transportation of excess mass from the larger of two sets A and B to some sink p ∈ X: where D is the ground distance, f * is the optimal flow, and we assume without loss of generality that µ(A) ≤ µ(B). The total cost of transforming one set into another is then given by where we have adopted the notation for Pele and Werman's EMD α . Note that p does not necessarily have to be in X (in which case we must replace D with an appropriate function in (15)). Ideally, though, p is a reserved point that does not naturally appear in the sets under consideration. Otherwise, there is a different type of potential identity loss. We define EMI as the kernel resulting from Lemma 1 with x 0 = ∅ and D = EMD p : Note that EMI is PD whenever EMD is CND for some collection of sets (and vice versa). By assuming p ∈ X, we can define a PD kernel K p according to Lemma 1 with x 0 = p and D as the ground distance, which we can then use with (15) to simplify EMI to Observe that the minimum-cost maximum flow with respect to D is the same as the maximum-cost maximum flow with respect to K p , regardless of the choice of p. As a result, EMI can be specified in terms of just a PD ground distance without explicitly specifying p. The definition of EMI also provides some insight into the pyramid match kernel (PMK) [24], which can be viewed as an approximation of EMI 0 on F(R n ). One may also consider an alternative def- As our first example of a situation in which EMI is PD on F(X) (and hence EMD and EMD are respectively CND on F(X) and P(X)), consider the discrete metric, which can trivially be verified to be CND. Define the discrete kernel corresponding to this ground distance to be K 0-1 (x, y) = 1 − δ 0-1 (x, y), which is PD. We can show that EMI in this case is equivalent to the intersection kernel.
Proposition 5. Let EMI 0-1 (A, B) be EMI equipped with the discrete kernel as the ground distance on an arbitrary set X. Then EMI 0-1 is equivalent to the intersection kernel.
Proof. The goal is to find the maximum-cost maximum flow subject to constraints, and the only way to increase the cost with the discrete kernel is to send available mass from a point in one set up to the capacity allowed by the other set at the same location. Therefore, f * (a, a) will be saturated up to the available capacity at a in each set, i.e. The cost to transport this mass is simply the amount of mass transported. The exact mapping of the remaining mass is irrelevant as it costs nothing to move. As a result, Since the intersection kernel is PD [33], we conclude that EMI 0-1 is as well. One can then deduce that EMD 0-1 and EMD 0-1 give measures of the set difference between A and B. Specifically, EMD 0-1 gives the set difference of the larger set from the smaller, and EMD 0-1 gives the set difference of the smaller set from the larger. The sum of both yields the symmetric difference. One may also apply (9) with K = EMI 0-1 or (13) with D = EMD 0-1 and p = ∅ to obtain the Jaccard index and distance.
Switching to a ground distance other than the discrete metric is like allowing a degree of uncertainty in element identity. The sharper or more concave the comparison function, the closer EMD and its derivatives are to their respective binary set operations. The point p is used to determine the cost of an unmatched element, which could potentially vary if some point is considered more important than another. Practically, thresholding a ground distance by some upper bound can be used to artificially induce concavity and make comparisons more strict.
Another result that can be derived as a special case of EMI follows.
Proposition 6. If there exists a function g : X → R such that the ground distance D(x, y) = g(x) + g(y), then EMI p = 0 and is trivially PD on F(X) for any choice of p.
Proof . Let f (a, b) be the maximum-cost maximum flow between sets A and B with respect to K p defined using Lemma 1 with x 0 = p. Note that in this case, K p (x, y) = 0. As a result, EMI p (A, B) = 0, which is trivially PD.
If g(p) ≥ 0 and we opt to use EMI by discarding D(p, p) in (15), then We expect there to be many other instances of PD kernels based either directly or indirectly on EMD. For example, Cuturi [34] proposed a regularized version of EMD via an additional entropic term that yields the exponent of the independence kernel (IDK), (a, b) , (18) when the entropic term's effect is maximized. Refer to Appendices B, C, D for further examples. One should note that the computation of EMI (or EMD) relies entirely on algorithms for computing EMD, so there is no significant difference computationally between the two.

V. EXPERIMENTS
In this section we describe experiments with classification using SVMs designed to demonstrate the utility of EMD as well as the utility of the definite-preserving transformation of Section III with respect to EMD. To our knowledge, EMD (not EMD) has not been applied in a kernel setting and we therefore perform the first such experiments. In particular, we evaluate the effect of choosing some different values of p (the sink to which excess mass is transported in our generalization of Pele and Werman's EMD). For each of the EMD variants, we make use of Theorem 1 to construct generalized radial basis function (RBF) kernels of the form exp (−uD EMD ), where D EMD is an EMD-based distance between sets. In order to avoid the overhead of tuning u via cross-validation, we assign u to be the inverse of the average value of D EMD on the training set as suggested by Zhang et al. [18].
We also show that when using unnormalized sets, especially when the magnitude of the mass has semantic significance relevant to classification, that EMD is superior to EMD. Since we are dealing with indefinite kernels, we evaluate the results in the context of two techniques designed to address the nonconvex optimization encountered in training SVMs with such kernels. The techniques mentioned are eigenvalue shifting of the kernel matrix and the Krein support vector machine (KSVM) recently proposed by [38]. Both methods were chosen for their relative simplicity of implementation as well as the fact that test points (or associated kernel evaluations) do not need to be modified. Where appropriate, these methods are balanced against SVMs trained directly with the indefinite kernels (see Tables III and IV).
Shift is a heuristic that involves shifting the eigenvalues of the kernel matrix to be non-negative (e.g. by adding sI to the kernel matrix, where s is the amount to shift each eigenvalue and I is the identity matrix). Shifting causes the SVM training problem to become convex, assuring a globally optimal solution. Wu et al. [39] show that shifting adds a regularization term that penalizes the norm of the support vector coefficients. Thus, simply choosing a very large s that guarantees PD-ness is not necessarily beneficial as it may constrain possible solutions. The smallest possible s (i.e. the magnitude of the least negative eigenvalue) is generally a good default choice. Approximations for s that assure PD-ness without requiring an eigendecomposition of the kernel matrix can be used. We did not make use of these approximations, however.
On the other hand, KSVM is formulated in the theory of Krein spaces (generalizations of Hilbert spaces with indefinite inner products) and may be considered a state-of-the-art indefinite kernel technique. Our results certainly reflect its ability to compensate for deficiencies in an indefinite kernel. However, KSVM is computationally expensive, requiring an eigendecomposition of the entire precomputed kernel matrix used for training. Therefore, Loosli et al. [38] also proposed KSVM-L, a more practical alternative that uses partial decompositions.
For completeness, we briefly describe the KSVM algorithm. Given a kernel matrix G K and label vector y containing ±1 for each respective positive or negative instance, one must compute an eigendecomposition of Y G K Y , where Y = diag (y) is an otherwise zero matrix with y on the diagonal. If U and D are the resulting eigenvector and eigenvalue matrices satisfying U DU = Y G K Y , then one trains the SVM using a standard solver with the PD kernel matrix G K = U SDU , where S = sign (D). Finally, one transforms the resulting support vector coefficients α (not to be confused with α in EMD α ) to obtain support vector coefficients α = U SU α in the original indefinite space. The solution is not sparse. One may note that KSVM is equivalent to flipping each negative eigenvalue of the kernel matrix to be positive prior to transforming the result. We also note that a one-versus-all scheme for multiclass SVMs has a distinct computational advantage over one-versus-one schemes since if y i is the label vector treating the i-th class as positive and the remainder negative and V contains the eigenvectors of G k , then U i = Y i V provides the eigenvectors of Y i G k Y i . Consequently, only one eigendecomposition is required regardless of the number of classes. We take advantage of this fact in our experiments; i.e. all results are computed using one-versus-all binary SVMs.
For select datasets (see Section V-B), we compare against more traditional kernels including linear, Gaussian, PMK [24], and IDK [34]. Linear and Gaussian kernels require special treatment as there is no obvious, uncontrived way for them to handle unordered sets of features. We lexicographically sorted the feature vectors of an instance and concatenated them prior to using each of the two former kernels, appending zeros for smaller instance sets. PMK consists of constructing a multiresolution d-dimensional histogram with resolutions ranging from 1 to L d bins. IDK is given by (18), and we use the same selection criteria for u here as we do for the other EMDbased kernels. The former three kernels are PD, whereas IDK is indefinite on unnormalized sets/histograms. We thus apply Shift and Krein SVM to IDK.

A. Datasets
Each considered kernel-EMD with Rubner's scaling, EMD, and its biotope transformation EMD T,p (hereafter referred to as earth mover's Jaccard distance (EMJD))was evaluated on four datasets: the texture database KTH-TIPS [40], the object category database Caltech-101 [41], a dataset Corner-MNIST (CMNIST) based on the handwritten character database MNIST [42], and a motion capture hand posture dataset collected by the authors 4 . The Euclidean distance served as the ground distance for each dataset except for Caltech-101, for which it was squared.
The KTH-TIPS database consists of 10 texture classes under varying scale, pose, and illumination with 81 instances per class. Images are standardized by resizing to a horizontal resolution of 480 pixels while preserving aspect ratio. We adopted much of the experimental design of Zhang et al. [18], constructing image signatures from SIFT descriptors. The SIFT descriptor [43] computes an N -bin histogram of image gradient orientations for an M × M grid of samples in the region of interest, resulting in an M × M × N dimensional vector. We used the implementation of the SIFT descriptor provided by Vedaldi and Fulkerson [44] with M = 4 and N = 8. The resulting 128-dimensional vectors were scaled to have a Euclidean norm of 1 to reduce the influence of illumination changes. The descriptors were then clustered using a k-means algorithm (with k = 40). Each mean was weighted with the percentage of descriptors assigned to it, and the means paired with these weights constituted the so-called signature for a single image.
A very similar feature extraction procedure was conducted for the Caltech-101 dataset composed of color images of 101 categories (e.g. face, car, etc.) with varied presentation. Instead of SIFT descriptors, the PHOW descriptor implemented by Vedaldi and Fulkerson [44] was used to represent images. At a high level, the PHOW descriptor is a dense SIFT extractor (the regions of interest are densely sampled in a grid) that can operate on multiple color channels instead of just grayscale. However, we simply used grayscale. Sets were normalized for both KTH-TIPS and Caltech-101.
The MNIST dataset comprises 28 × 28 grayscale images of handwritten digits ranging from 0 to 9. CMNIST was created in the following manner. Noble's version [45] of the Harris corner detector [46] was used to identify keypoints in each image (implemention again provided by Vedaldi and Fulkerson [44]). Images were smoothed with a Gaussian window with a variance of 1 prior to application of the Harris response function, which also used a Gaussian window with a variance of 1. Local maxima in the response were interpreted as corners. The set of coordinates (scaled to lie between 0 and 1) of these detected corners then constitute the features of the image with the expected number of corners and their locations depending upon the digit. The number of detected corners typically ranged from 5 to 15.
The final dataset consists of variable size unlabeled 3D point set examples of 5 hand postures captured in a Vicon motion capture environment for 12 users. Each unlabeled point represents the 3D position of a motion capture marker attached to a glove in a coordinate system localized to the user's hand (via a rigid pattern of labeled markers affixed to the back of the glove). Eleven unlabeled markers were attached to the glove. However, not all markers are necessarily detected at a given time due to occlusion and the relative size of the markers with respect to the capture space. Therefore, the number of unlabeled points in an instance ranges from 3 to 12 (extraneous markers, though uncommon, are also possible). Markers more than 200 millimeters from the local origin were pruned, and sets with fewer than 3 markers were discarded. No other preprocessing or feature extraction was necessary; points remained at millimeter scale.

B. Design of Experiments
Each experiment on each dataset involves the choice of a different sink p to which excess mass is sent. If the ground distance is thresholded and p lies beyond the threshold for every point in the training and test sets, then one can use a flat rate equal to the threshold as the cost of transporting excess mass. Therefore, we simply use the threshold to identify different experiments. The thresholds used are reported in the provided tables (e.g. Table I). One will note that the bottom row of each table has no threshold (denoted by a dash), and in this case p was generally chosen to be the origin with the exception of CMNIST, where it was chosen to be the center of an image, 0.5, 0.5 . In the case of KTH-TIPS and Caltech-101, choosing the origin is not much different than choosing a threshold of 1 since every point lies on the surface of a unit hypersphere. The advantage of flat thresholds lies in their simplicity of implementation (the precise value of the optimal flow is irrelevant) as well as the ability to use certain faster algorithms [5]. In addition, IDK is compatible with thresholded ground distances, but the concept of a sink p does not apply (hence the N/A entries in Tables III and IV). Linear, Gaussian, and PMK kernels, on the other hand, do not use a ground distance at all, and thus their results are presented separately in Table II. We only evaluated these alternative kernels on CMNIST and the posture recognition dataset. For PMK, we chose L = 128 for CMNIST and L = 256 for posture recognition.
The following data selection schemes were repeated for each experiment (threshold) with the exception that the selection of data for experiments with no threshold matched that of the highest threshold in order to enable a direct comparison. For KTH-TIPS (and Caltech-101), 40 (15) images from each class were randomly drawn to be the training set with an equivalently drawn disjoint test set. This random selection was repeated 5 times in order to obtain 5 training/test set pairs, the results of which were averaged. For CMNIST, 200 examples from each class were randomly chosen and 5-fold cross validation was computed for each experiment. For the posture recognition dataset, special consideration was required due to the fact that there is signficant correlation and even near duplication for samples corresponding to a single user. Therefore, a leave-one-user-out approach was employed where each of the 12 users served in turn as the test set. As a result, experiments measured the generalization of the classifier to new users. The dataset's size was reduced and classes balanced by randomly selecting 75 examples per class per user.

C. Results and Discussion
For normalized sets contained in KTH-TIPS and Caltech-101 (Table I), there is no significant difference between the three kernels. The main point we make with these two datasets is that there is no degradation in performance when using EMD or EMJD versus EMD. In fact, EMD and EMD are the exact same for any two normalized sets since the difference in mass is zero. However, for unnormalized sets (Tables III and IV), EMD and EMJD are noticeably better than EMD despite the indefinite kernel techniques. KSVM actually improved EMD's accuracy far beyond what was expected, nearly matching EMD's performance (and surpassing it on the highest thresholds for CMNIST). However, this state-of-the-art indefinite kernel technique was still unable to bridge the difference in all cases, and the results should be balanced by the more computationally practical Shift, which was completely unable to compensate for EMD's indefiniteness.
Our experiments on KTH-TIPS and Caltech-101 confirmed the report of Zhang et al. [18] that the RBF kernel for EMD is PD with this data. However, computation of EMI revealed an indefinite kernel matrix, which indicates that only a subset of u < 0 from Theorem 1 is satisfied and that Zhang et al.'s selection strategy for u just happens to fall within this subset. The same behavior was observed for EMJD on these two datasets. The ground distance's support for posture recognition and CMNIST, on the other hand, does not consist    N/A of normalized vectors. For posture recognition, we noticed that EMJD was more likely to yield a PD RBF using the aforementioned selection strategy. For example, observe that the Shift and KSVM results are the same as the indefinite results for certain thresholds, with lower threshelds apparently increasing the likelihood of generating a PD kernel. Exploration on normalized sets (not shown) with both CMNIST and posture recognition made this effect more pronounced. Of special note is the fact that EMD and EMJD yield significant improvements in accuracy even without applying any indefinite kernel technique. On the posture recognition dataset in particular, the effective results are nearly indistinguishable from Shift and KSVM. For the CMNIST dataset, indefinite EMJD consistently outperformed the other two kernels and rivaled Shift and KSVM at the lowest threshold. These results indicate that EMD, EMJD, and perhaps the definite-preserving transformation in general have value on their own without additional indefinite kernel methods.
A comparison against the more traditional kernels (Table II  and the IDK columns of Tables III and IV) only reinforces this conclusion. Though IDK performed comparably well on CMNIST with Krein SVM, it performed considerably worse in all other cases and appeared to be insensitive to changes in the threshold. The PD kernels performed relatively poorly as well, although the linear and Gaussian kernels performed surprisingly well for posture recognition compared to both PMK and IDK.
In general, one can observe that the threshold has a significant effect on the quality of the classifier. The highest thresholds, which matched or exceeded the diameter of each dataset's support, did not yield the best observed results for any dataset. Lower thresholds tended to yield better results (up to a point). As the threshold lowers, EMD becomes a closer approximation to the set symmetric difference and thus more similar to the intersection kernel. As stated in Section IV, thresholding can be interpreted as a means to induce concavity in the ground distance and make it more similar to the discrete metric. This explains why the accuracy drops off after a certain minimum threshold (as it becomes too similar to classical intersection to associate slightly different elements) as well as its tendency to improve prior to the drop off.

VI. CONCLUSION
In this paper we presented proof that PD kernels can be derived via Lemma 1 from EMD and are dependent on the ground distance and the space in which it operates. We set our discussions in the context of set theory, providing motivation for our derivations and an intuitive interpretation of EMD's value, namely as a generalization of otherwise binary set operations. In doing so, we generalized EMD for kernels. We also proposed a PD-preserving transformation that normalizes a kernel's values and showed that the Jaccard index is simply the transformation of the intersection kernel. As a corollary, the biotope transform was shown to preserve CND as well asmetric properties. Finally, we provided the first assessment of EMD in a kernel setting and showed that it and its biotope transform EMJD achieve superior accuracy over EMD on experiments with unnormalized sets and a state-ofthe-art indefinite kernel technique. Indeed, we showed that an indefinite kernel technique may not even be necessary. EMJD was found to have more favorable numerical properties than EMD.
Our work raised some open questions. We do not know whether thresholding a distance preserves CND properties as it does metric properties [5]. Our experiments did not contradict the hypothesis. The choice of the optimal threshold is also open. One could always tune the threshold via cross-validation, but we suspect that a decent approximation to the optimal threshold would be to use the average or median distance between all points. Using no threshold or choosing p to be closer than the threshold is also an option to consider as the posture recognition experiments demonstrate.
One unexpected result was KSVM's poor performance on CMNIST relative to Shift for EMD and EMJD. This result is at odds with the expectation that KSVM should be at least as good as other indefinite kernel techniques, which is fairly well justified in its introductory article [38]. We noted that the eigenspectrum of a CMNIST kernel matrix was much less concentrated than those for the other datasets. Whereas performing a partial decomposition with the 50 highest magnitude eigenvalues was typically sufficient to retain approximately 95% of the spectrum's total magnitude on the other datasets, as many as 1200 eigenvalues were required to achieve the same preservation of the spectrum on CMNIST. In fact, the results reported in Table III are from a complete decomposition. Additional research may be required to determine if this is due to a peculiarity unique to CMNIST or some property of KSVM.

APPENDIX A NESTED TRANSFORMATIONS
This Appendix gives proofs of Propositions 3 and 4 and introduces Proposition 7. In Appendix D, we use Proposition 4 to find ground distances for which EMD is CND.
Proof of Proposition 3. By (9) and (10), we trivially see that if x = y, T (n) [K] (x, y) = 1 for all n. If x = y, , we deduce from (12) that T [K] (x, y) < 1 and Noting that the geometric sequence a n = |T [K] (x, y)/r n−1 |, where r = 2 − T [K] (x, y) if T [K] (x, y) > 0 and r = 2 otherwise, converges to 0 as n → ∞, we conclude that the sequence b n = |T (n) [K] (x, y)|, which is bounded below by 0 and above by a n for n ≥ 1, also converges to 0 by the squeeze theorem [47]. The proposition follows.
Proposition 7. For any given K : X × X → R, Proof. We prove this via induction. As a base case, note that n = 1 yields (9). Now suppose that the proposition holds for some n − 1, n > 1. Then by (10), .
Note that although we focused on n ≥ 1, n could be considered a continuous hyperparameter within the range (−∞, ∞). If n = 0, then we obtain a generalization of the F measure (as interpreted as a kernel by Ralaivola et al. [25]) 2K(x, y) K(x, x) + K(y, y) .
PD-ness is not guaranteed for n < 0.
Proof of Proposition 4. Consider the kernel matrix G for some selection of elements x 1 , . . . , x n ∈ X with 1 ≤ i, j ≤ n. Since the definition of a PD kernel requires only distinct elements for (1), we may without loss of generality assume that each element is distinct, i.e. i = j =⇒ x i = x j . We show that lim n→∞ G (n) K = I, and hence its eigenvalues each converge to 1, implying that the minimum eigenvalue must be greater than or equal to 0 for some n 0 and thus G (n) K is PD for n ≥ n 0 . We show this by proving a stronger version of (11). Note that since the considered kernel K is not necessarily PD, T [K] is not necessarily in the interval [−1/3, 1]. However, T [K] (x, x) = 1 for any x ∈ X. More importantly, the derivation of (11) holds if T [K] (x, y) < 1, regardless of the magnitude |T [K] (x, y)|. Therefore, it is sufficient to show that T (n) [K] (x, y) eventually becomes negative for any x, y such that T [K] (x, y) > 1. We consider three cases: Note T (2) [K] (x, y) < 0 since the denominator of (10) after substitution is negative but the numerator is positive. 2) T [K] (x, y) = 2.

3) T [K] (x, y) ∈ (1, 2).
Note that T (2) [K] (x, y) > T [K] (x, y) since the denominator of (10) after subtitution will be less than one. Furthermore, the denominator decreases with each iteration, which implies that T (n) [K] (x, y) will increase until it falls within one of the previous two categories. Thus lim n→∞ T (n) [K] (x i , x j ) = 0 for x i = x j and lim n→∞ G If D is CND, then one can show that EMD equipped with D is CND as well. A well known result [48] states that EMD between two probability distributions u, v ∈ P(R) with a ground distance such as D can be written where U −1 and V −1 are the inverse cumulative distribution functions of u and v. In essence, the i-th point in ascending order of one distribution maps to the i-th point of the other. Since EMD in this form is clearly just the summation of CND functions, then EMD must also be CND.
Kolouri et al. [49] use D(a, b) = (a − b) 2 to show that the sliced Wasserstein kernel, which is calculated between distributions in R d via one-dimensional projections, is PD. One may also consider the following special case to reveal similarities to another min-like kernel, the Brownian bridge product kernel [50], [51], Suppose the ground distance D is supported by two points p 1 , p 2 ∈ R, and without loss of generality assume p 1 = −p 2 = 1. Assuming u, v ∈ P({p 1 , p 2 }), let χ u (p 1 ) = x and χ v (p 1 ) = y so that χ u (p 2 ) = 1 − x and χ v (p 2 ) = 1 − y.

APPENDIX C TRANSPORTATION ON THE CIRCLE
Transportation on the circle is similar to transportation on the real line. In fact, one simply has to find an optimal point at which to cut the circle prior to treating it like the real line. In this case, the geodesic distance (i.e. length of arc or angle) is used to compare points. If the points x, y are linearly indexed on S 1 , the circle with radius 1, then or equivalently D(x, y) = arccos cos(x) sin(x) cos(y) sin(y) , which is provably CND by an infinite series expansion [52]. With the given ground distance and probability distributions u, v ∈ P(S 1 ), it can be shown that (19) where U and V are cumulative distribution functions and α is the weighted median of U − V [48], [53]. Surprisingly, one can empirically show that for arbitrary u and v, EMD is not CND on the circle despite its similarity to the line.
The reason that EMD is not CND on the circle is due to the use of the median in (19). If we approximate the median with the mean (guaranteed by Jensen's inequality to be within 1 standard deviation [54]), then we obtain a CND approximation of EMD. Note that substituting the mean in (19) yields which is a sum of CND kernels. If the median can be expressed by a function h as α = h(u) − h(v) (perhaps only for certain families of distributions), then EMD is CND. APPENDIX D TRANSPORTATION ON THE L 2 HYPERSPHERE Consider the class of ground distances of the form β − K, where β is a positive constant and K is PD. This class of ground distances coincides with those implied by CND EMD α since we may note that Pele and Werman's EMD α is a special case formulation of (16) that uses D(a, p) = α max{D(a, b)} for every a, b ∈ X. If a point p can be found or created such that D(a, p) = β for each a ∈ X \ {p} and D is CND, then by Lemma 1 we can conclude that D is of the form β − K (in this case, β = 2α max D(a, b) − D(p, p)). A characterization of kernels of this form is given by Berg et al. [31]. If we add the condition that D satisfies identity of indiscernibles, then a geometric interpretation of D is readily forthcoming. In particular, the image φ(X) from K's feature mapping lies on the hypersphere of radius √ β in a Hilbert space centered on the point φ(p) = 0. This follows from the fact that K(a, a) = β as a consequence of D(a, a) = 0. In other words, this subclass is comprised of normalized kernels and embeds into squared L 2 on the hypersphere.
Ground distances of this form have already appeared in the literature. Rabin et al. [48] considered geodesic distances on the circle and used them for color image retrieval and color transfer between images. The geodesic distance is equivalent to the angle between two vectors representing points on the circle, which can be computed from the arc-cosine of their dot product, which is of the form β − K where β = π/2 and K is the arc-sine of their dot product. Zhang et al. [18] used a Euclidean ground distance in a high-dimensional space to compare SIFT descriptors for object and texture recognition in images. However, they normalized the vectors comprising each set's support, effectively restricting their computations to distance between points on the hypersphere. This study provided empirical evidence that EMD tends to be CND for this restricted case since no violations were found.
However, the result of Naor and Schechtman [19] states that EMD is indefinite on the {0, 1} 2 ⊂ R 2 grid with a Euclidean ground distance. We can thus conclude that EMD is actually not CND for ground distances of the form β − K in general since one can find a subspace of the hypersphere isometric to {0, 1} 2 . Consequently, any ground distance must necessarily not include subspaces isometric to {0, 1} 2 if there is any hope for EMD to be CND. We do have one example, though, of a ground distance of this form-the discrete metric-where EMD is CND, and we hypothesize that ground distances close to discrete in form are also sufficient. More formally, we hypothesize that there exists > 0 such that if K(x, x) = 1 for all x ∈ X and K(x, y) < for all x = y, then EMI equipped with K is PD. We will now illustrate this notion with a method that transforms a ground distance into a nearly discrete form in order to yield CND EMD.
Under the following assumptions about the distribution of the sets under consideration for use with EMD, we may use Proposition 4 to show that there exists a transformed ground distance of the form β − K that yields CND EMD. The assumptions that we make are that the sets are discrete, the collection of sets is finite, and that each pair of sets is disjoint. Note that these assumptions form sufficient but not necessary conditions for the strategy that follows. We also assume that K strictly satisfies (12) for different x, y but is not necessarily PD. One may then infer that there exists a number n 0 for which T (n) [K] is PD for n ≥ n 0 .
Let X 1 , X 2 , . . . , X n ∈ F(X) be subsets of X discretely supported with support cardinalities s i , i ∈ [1, n]. Let K j i be the s i × s j kernel matrix computed between the elements of X i and X j , and let Let H j i be the Schur product of F j i and K j i . Note that H i i is diagonal for each i as a consequence of (12). Additionally, H i j = H j i , and By an application of the derived subsets kernel [30], we may deduce that EMI is PD if the kernel matrix G H , where the (i, j)-th block G H (i, j) = H j i , is PD, i.e. if H : X * ×X * → R is a PD kernel, where X * = n i=1 X i . There are several ways one may proceed to obtain PD EMI. One may transform K and either keep or recompute the flow. One may also transform H or EMI itself. Since the sets are disjoint and K satisfies the conditions of Proposition 4, then H and EMI satisfy the same conditions. By Proposition 4, repeated transformation of H or EMI will eventually become PD. Transforming only K is slightly more complicated to analyze, but one may note by similar reasoning used in the proof of Proposition 4 that G H must eventually become PD since it converges to a diagonal matrix. Note that we do not endorse this scheme for use with any ground distance, and we hypothesize that it is most appropriate for ground distances that are already normalized, i.e. of the form β − K.