2461 Out of Sample Extensions For Lle Isomap Mds Eigenmaps and Spectral Clustering

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Out-of-Sample Extensions for LLE, Isomap,

MDS, Eigenmaps, and Spectral Clustering

Yoshua Bengio, Jean-François Paiement, Pascal Vincent


Olivier Delalleau, Nicolas Le Roux and Marie Ouimet
Département d’Informatique et Recherche Opérationnelle
Université de Montréal
Montréal, Québec, Canada, H3C 3J7
{bengioy,vincentp,paiemeje,delallea,lerouxni,ouimema}
@iro.umontreal.ca

Abstract
Several unsupervised learning algorithms based on an eigendecompo-
sition provide either an embedding or a clustering only for given train-
ing points, with no straightforward extension for out-of-sample examples
short of recomputing eigenvectors. This paper provides a unified frame-
work for extending Local Linear Embedding (LLE), Isomap, Laplacian
Eigenmaps, Multi-Dimensional Scaling (for dimensionality reduction)
as well as for Spectral Clustering. This framework is based on seeing
these algorithms as learning eigenfunctions of a data-dependent kernel.
Numerical experiments show that the generalizations performed have a
level of error comparable to the variability of the embedding algorithms
due to the choice of training data.
1 Introduction
Many unsupervised learning algorithms have been recently proposed, all using an eigen-
decomposition for obtaining a lower-dimensional embedding of data lying on a non-linear
manifold: Local Linear Embedding (LLE) (Roweis and Saul, 2000), Isomap (Tenenbaum,
de Silva and Langford, 2000) and Laplacian Eigenmaps (Belkin and Niyogi, 2003). There
are also many variants of Spectral Clustering (Weiss, 1999; Ng, Jordan and Weiss, 2002), in
which such an embedding is an intermediate step before obtaining a clustering of the data
that can capture flat, elongated and even curved clusters. The two tasks (manifold learning
and clustering) are linked because the clusters found by spectral clustering can be arbitrary
curved manifolds (as long as there is enough data to locally capture their curvature).

2 Common Framework
In this paper we consider five types of unsupervised learning algorithms that can be cast
in the same framework, based on the computation of an embedding for the training points
obtained from the principal eigenvectors of a symmetric matrix.
Algorithm 1
1. Start from a data set D = {x1 , . . . , xn } with n points in Rd . Construct a n × n
“neighborhood” or similarity matrix M . Let us denote KD (·, ·) (or K for shorthand) the
data-dependent function which produces M by Mij = KD (xi , xj ).
2. Optionally transform M , yielding a “normalized” matrix M̃ . Equivalently, this corre-
sponds to generating M̃ from a K̃D by M̃ij = K̃D (xi , xj ).
3. Compute the m largest positive eigenvalues λk and eigenvectors vk of M̃ .
4. The embedding of each example xi is the vector yi with yik the i-th element of the k -th
√ eigenvector vk of M̃ . Alternatively (MDS and Isomap), the embedding is ei , with
principal
eik = λk yik . If the first m eigenvalues are positive, then ei · ej is the best approximation
of M̃ij using only m coordinates, in the squared error sense.
In the following, we consider the specializations of Algorithm 1 for different unsupervised
learning algorithms. Let Si be the i-th row sum of the affinity matrix M :
X
Si = Mij . (1)
j

We say that two points (a, b) are k-nearest-neighbors of each other if a is among the k
nearest neighbors of b in D ∪ {a} or vice-versa. We denote by xij the j-th coordinate of
the vector xi .
2.1 Multi-Dimensional Scaling
Multi-Dimensional Scaling (MDS) starts from a notion of distance or affinity K that is
computed between each pair of training examples. We consider here metric MDS (Cox
and Cox, 1994). For the normalization step 2 in Algorithm 1, these distances are converted
to equivalent dot products using the “double-centering” formula: !
1 1 1 1 X
M̃ij = − Mij − Si − Sj + 2 Sk . (2)
2 n n n
k

The embedding eik of example xi is given by λk vki .
2.2 Spectral Clustering
Spectral clustering (Weiss, 1999) can yield impressively good results where traditional
clustering looking for “round blobs” in the data, such as K-means, would fail miserably. It
is based on two main steps: first embedding the data points in a space in which clusters are
more “obvious” (using the eigenvectors of a Gram matrix), and then applying a classical
clustering algorithm such as K-means, e.g. as in (Ng, Jordan and Weiss, 2002). The affinity
matrix M is formed using a kernel such as the Gaussian kernel. Several normalization steps
have been proposed. Among the most successful ones, as advocated in (Weiss, 1999; Ng,
Jordan and Weiss, 2002), is the following:
Mij
M̃ij = p . (3)
Si Sj
To obtain m clusters, the first m principal eigenvectors of M̃ are computed and K-means
is applied on the unit-norm coordinates, obtained from the embedding yik = vki .
2.3 Laplacian Eigenmaps
Laplacian Eigenmaps is a recently proposed dimensionality reduction procedure (Belkin
and Niyogi, 2003) that has been proposed for semi-supervised learning. The authors use
an approximation of the Laplacian operator such as the Gaussian kernel or the matrix whose
element (i, j) is 1 if xi and xj are k-nearest-neighbors and 0 otherwise. Instead of solving
an ordinary eigenproblem, the following generalized eigenproblem is solved:
(S − M )vj = λj Svj (4)
with eigenvalues λj , eigenvectors vj and S the diagonal matrix with entries given by eq. (1).
The smallest eigenvalue is left out and the eigenvectors corresponding to the other small
eigenvalues are used for the embedding. This is the same embedding that is computed
with the spectral clustering algorithm from (Shi and Malik, 1997). As noted in (Weiss,
1999) (Normalization Lemma 1), an equivalent result (up to a componentwise scaling of
the embedding) can be obtained by considering the principal eigenvectors of the normalized
matrix defined in eq. (3).
2.4 Isomap
Isomap (Tenenbaum, de Silva and Langford, 2000) generalizes MDS to non-linear mani-
folds. It is based on replacing the Euclidean distance by an approximation of the geodesic
distance on the manifold. We define the geodesic distance with respect to a data set D, a
distance d(u, v) and a neighborhood k as follows:
X
D̃(a, b) = min d(pi , pi+1 ) (5)
p
i

where p is a sequence of points of length l ≥ 2 with p1 = a, pl = b, pi ∈ D ∀i ∈


{2, . . . , l − 1} and (pi ,pi+1 ) are k-nearest-neighbors. The length l is free in the minimiza-
tion. The Isomap algorithm obtains the normalized matrix M̃ from which the embedding
is derived by transforming the raw pairwise distances matrix as follows: first compute the
matrix Mij = D̃2 (xi , xj ) of squared geodesic distances with respect to the data D, then
apply to this matrix the distance-to-dot-product
√ transformation (eq. (2)), as for MDS. As in
MDS, the embedding is eik = λk vki rather than yik = vki .
2.5 LLE
The Local Linear Embedding (LLE) algorithm (Roweis and Saul, 2000) looks for an em-
bedding that preserves the local geometry in the neighborhood of eachP data point. First, a
sparse matrix of local predictive weights Wij is computed, such that j Wij = 1, Wij = 0
if xj is not a k-nearest-neighbor of xi and ( j Wij xj −xi )2 is minimized. Then the matrix
P

M = (I − W )0 (I − W ) (6)
is formed. The embedding is obtained from the lowest eigenvectors of M , except for the
smallest eigenvector which is uninteresting because it is (1, 1, . . . 1), with eigenvalue 0.
Note that the lowest eigenvectors of M are the largest eigenvectors of M̃µ = µI − M to
fit Algorithm 1 (the use of µ > 0 will be discussed in section 4.4). The embedding is given
by yik = vki , and is constant with respect to µ.
3 From Eigenvectors to Eigenfunctions
To obtain an embedding for a new data point, we propose to use the Nyström formula (eq. 9)
(Baker, 1977), which has been used successfully to speed-up kernel methods computations
by focussing the heavier computations (the eigendecomposition) on a subset of examples.
The use of this formula can be justified by considering the convergence of eigenvectors
and eigenvalues, as the number of examples increases (Baker, 1977; Williams and Seeger,
2000; Koltchinskii and Giné, 2000; Shawe-Taylor and Williams, 2003). Intuitively, the
extensions to obtain the embedding for a new example require specifying a new column of
the Gram matrix M̃ , through a training-set dependent kernel function K̃D , in which one of
the arguments may be required to be in the training set.
If we start from a data set D, obtain an embedding for its elements, and add more and
more data, the embedding for the points in D converges (for eigenvalues that are unique).
(Shawe-Taylor and Williams, 2003) give bounds on the convergence error (in the case of
kernel PCA). In the limit, we expect each eigenvector to converge to an eigenfunction for
the linear operator defined below, in the sense that the i-th element of the k-th eigenvector
converges to the application of the k-th eigenfunction to xi (up to a normalization factor).
R
Consider a Hilbert space Hp of functions with inner product hf, gip = f (x)g(x)p(x)dx,
with a density function p(x). Associate with
Z kernel K a linear operator Kp in Hp :
(Kp f )(x) = K(x, y)f (y)p(y)dy. (7)

We don’t know the true density p but we can approximate the above inner product and
linear operator (and its eigenfunctions) using the empirical distribution p̂. An “empirical”
Hilbert space Hp̂ is thus defined using p̂ instead of p. Note that the proposition below can be
applied even if the kernel is not positive semi-definite, although the embedding algorithms
we have studied are restricted to using the principal coordinates associated with positive
eigenvalues. For a more rigorous mathematical analysis, see (Bengio et al., 2003).
Proposition 1
Let K̃(a, b) be a kernel function, not necessarily positive semi-definite, that gives rise to
a symmetric matrix M̃ with entries M̃ij = K̃(xi , xj ) upon a dataset D = {x1 , . . . , xn }.
Let (vk , λk ) be an (eigenvector,eigenvalue) pair that solves M̃ vk = λk vk . Let (fk , λ0k )
fk )(x) = λ0k fk (x) for any x, with p̂
be an (eigenfunction,eigenvalue) pair that solves (K̃p̂√
the empirical distribution over D. Let ek (x) = yk (x) λk or yk (x) denote the embedding
associated with a new point x. Then
1
λ0k = λk (8)
n
√ X n
n
fk (x) = vki K̃(x, xi ) (9)
λk i=1

fk (xi ) = nvki (10)
n
fk (x) 1 X
yk (x) = √ = vki K̃(x, xi ) (11)
n λk i=1
yk (xi ) = yik , ek (xi ) = eik (12)
See (Bengio et al., 2003) for a proof and further justifications
√ of the above formulae. The
generalized embedding for Isomap and MDS is ek (x) = λk yk (x) whereas the one for
spectral clustering, Laplacian eigenmaps and LLE is yk (x).
Proposition 2
In addition, if the data-dependent kernel K̃D is positive semi-definite, then
r
n
fk (x) = πk (x)
λk
where πk (x) is the k-th component of the kernel PCA projection of x obtained from the
kernel K̃D (up to centering).
This relation with kernel PCA (Schölkopf, Smola and Müller, 1998), already pointed out
in (Williams and Seeger, 2000), is further discussed in (Bengio et al., 2003).

4 Extending to new Points


Using Proposition 1, one obtains a natural extension of all the unsupervised learning algo-
rithms mapped to Algorithm 1, provided we can write down a kernel function K̃ that gives
rise to the matrix M̃ on D, and can be used in eq. (11) to generalize the embedding. We
consider each of them in turn below. In addition to the convergence properties discussed in
section 3, another justification for using equation (9) is given by the following proposition:
Proposition 3
If we define the fk (xi ) by eq. (10) and take a new point x, the value of fk (x) that minimizes
n m
!2
X X
0
K̃(x, xi ) − λt ft (x)ft (xi ) (13)
i=1 t=1

is given by eq. (9), for m ≥ 1 and any k ≤ m.


The proof is a direct consequence of the orthogonality of the eigenvectors v k . This proposi-
tion links equations (9) and (10). Indeed, we can obtain eq. (10) when trying to approximate
K̃ at the data points by minimizing the cost !2
Xn m
X
0
K̃(xi , xj ) − λt ft (xi )ft (xj )
i,j=1 t=1

for m = 1, 2, . . . When we add a new point x, it is thus natural to use the same cost to
approximate the K̃(x, xi ), which yields (13). Note that by doing so, we do not seek to
approximate K̃(x, x). Future work should investigate embeddings which minimize the
empirical reconstruction error of K̃ but ignore the diagonal contributions.
4.1 Extending MDS
For MDS, a normalized kernel can be defined as follows, using a continuous version of the
double-centering eq. (2):
1
K̃(a, b) = − (d2 (a, b) − Ex [d2 (x, b)] − Ex0 [d2 (a, x0 )] + Ex,x0 [d2 (x, x0 )]) (14)
2
where d(a, b) is the original distance and the expectations are taken over the empirical data
D. An extension of metric MDS to new points has already been proposed in (Gower, 1968),
solving exactly for the embedding of x to be consistent with its distances to training points,
which in general requires adding a new dimension.
4.2 Extending Spectral Clustering and Laplacian Eigenmaps
Both the version of Spectral Clustering and Laplacian Eigenmaps described above are
based on an initial kernel K, such as the Gaussian or nearest-neighbor kernel. An equiva-
lent normalized kernel is:
1 K(a, b)
K̃(a, b) = p
n Ex [K(a, x)]Ex0 [K(b, x0 )]
where the expectations are taken over the empirical data D.
4.3 Extending Isomap
To extend Isomap, the test point is not used in computing the geodesic distance between
training points, otherwise we would have to recompute all the geodesic distances. A rea-
sonable solution is to use the definition of D̃(a, b) in eq. (5), which only uses the training
points in the intermediate points on the path from a to b. We obtain a normalized kernel by
applying the continuous double-centering of eq. (14) with d = D̃.
A formula has already been proposed (de Silva and Tenenbaum, 2003) to approximate
Isomap using only a subset of the examples (the “landmark” points) to compute the eigen-
vectors. Using our notations, this formula is
1 X
e0k (x) = √ vki (Ex0 [D̃2 (x0 , xi )] − D̃2 (xi , x)). (15)
2 λk i
where Ex0 is an average over the data set. The formula is applied to obtain an embedding
for the non-landmark examples.
Corollary 1
The embedding proposed in Proposition 1 for Isomap (ek (x)) is equal to formula 15 (Land-
mark Isomap) when K̃(x, y) is defined as in eq. (14) with d = D̃.
P
Proof: the proof relies on a property of the Gram matrix for Isomap: i Mij = 0, by con-
struction. Therefore (1, 1, . . . 1)
Pis an eigenvector with eigenvalue 0, and all the other eigen-
vectors vk have the property i vki = 0 because of the orthogonality with (1, 1, . . . 1).
Writing (Ex0 [D̃2 (x0 , xi )]− D̃2 (x, xi )) = 2K̃(x, xi )+Ex0 ,x00 [D̃2 (x0 , x00 )]−Ex0 [D̃2 (x, x0 )]
yields e0k (x) = 2√2λ 2 0 2
P 00 0
P
k i vki K̃(x, xi ) + (Ex0 ,x00 [D̃ (x , x )] − Ex0 [D̃ (x, x )]) i vki =
ek (x), since the last sum is 0.
4.4 Extending LLE
The extension of LLE is the most challenging one because it does not fit as well the frame-
work of Algorithm 1: the M matrix for LLE does not have a clear interpretation in terms
of distance or dot product. An extension has been proposed in (Saul and Roweis, 2002),
but unfortunately it cannot be cast directly into the framework of Proposition 1. Their
embedding of a new point x is given by
Xn
yk (x) = yk (xi )w(x, xi ) (16)
i=1

where w(x, xi ) is the weight of xi in the reconstruction of x by its k-nearest-neighbors in


the training set (if x = xj ∈ D, w(x, xi ) = δij ). This is very close to eq. (11), but lacks the
normalization by λk . However, we can see this embedding as a limit case of Proposition 1,
as shown below.
We first need to define a kernel K̃µ such that
X
K̃µ (xi , xj ) = M̃µ,ij = (µ − 1)δij + Wij + Wji − Wki Wkj (17)
k

for xi , xj ∈ D. Let us define a kernel K̃ 0 by


K̃ 0 (xi , x) = K̃ 0 (x, xi ) = w(x, xi )

and K̃ 0 (x, y) = 0 when neither x nor y is in the training set D. Let K̃ 00 be defined by
X
K̃ 00 (xi , xj ) = Wij + Wji − Wki Wkj
k

and K̃ 00 (x, y) = 0 when either x or y isn’t in D. Then, by construction, the kernel K̃µ =
(µ − 1)K̃ 0 + K̃ 00 verifies eq. (17). Thus, we can apply eq. (11) to obtain an embedding of
a new point x, which yields
1 X  
yµ,k (x) = yik (µ − 1)K̃ 0 (x, xi ) + K̃ 00 (x, xi )
λk i

with λk = (µ − λ̂k ), and λ̂k being the k-th lowest eigenvalue of M . This rewrites into
µ−1 X 1 X
yµ,k (x) = yik w(x, xi ) + yik K̃ 00 (x, xi ).
µ − λ̂k i µ − λ̂k i

Then when µ → ∞, yµ,k (x) → yk (x) defined by eq. (16).


Since the choice of µ is free, we can thus consider eq. (16) as approximating the use of the
kernel K̃µ with a large µ in Proposition 1. This is what we have done in the experiments
described in the next section. Note however that we can find smoother kernels K̃µ verifying
eq. (17), giving other extensions of LLE from Proposition 1. It is out of the scope of this
paper to study which kernel is best for generalization, but it seems desirable to use a smooth
kernel that would take into account not only the reconstruction of x by its neighbors x i , but
also the reconstruction of the xi by their neighbors including the new point x.

5 Experiments
We want to evaluate whether the precision of the generalizations suggested in the pre-
vious section is comparable to the intrinsic perturbations of the embedding algorithms.
The perturbation analysis will be achieved by considering splits of the data in three sets,
D = F ∪ R1 ∪ R2 and training either with F ∪ R1 or F ∪ R2 , comparing the embeddings
on F . For each algorithm described in section 2, we apply the following procedure:
4
x 10 4
10 x 10

20
8

6 15

4
10

0
-2

-4 -5
0 0.05 0.1 0.15 0.2 0.25 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4
3
x 10
7 1

6
0.8

0.6
4

3
0.4

0.2
1

0 0

-1

-0. 2
-2

-3 -0. 4
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0 0.05 0.1 0.15 0.2 0.25

Figure 1: Training set variability minus out-of-sample error, wrt the proportion of training
samples substituted. Top left: MDS. Top right: spectral clustering or Laplacian eigenmaps.
Bottom left: Isomap. Bottom right: LLE. Error bars are 95% confidence intervals.

1. We choose F ⊂ D with m = |F | samples. The remaining n − m samples in D/F


are split into two equal size subsets R1 and R2 . We train (obtain the eigenvectors)
over F ∪ R1 and F ∪ R2 . When eigenvalues are close, the estimated eigenvectors
are unstable and can rotate in the subspace they span. Thus we estimate an affine
alignment between the two embeddings using the points in F , and we calculate
the Euclidean distance between the aligned embeddings obtained for each s i ∈ F .
2. For each sample si ∈ F , we also train over {F ∪ R1 }/{si }. We apply the exten-
sion to out-of-sample points to find the predicted embedding of si and calculate
the Euclidean distance between this embedding and the one obtained when train-
ing with F ∪ R1 , i.e. with si in the training set.
3. We calculate the mean difference (and its standard error, shown in the figure)
between the distance obtained in step 1 and the one obtained in step 2 for each
sample si ∈ F , and we repeat this experiment for various sizes of F .

The results obtained for MDS, Isomap, spectral clustering and LLE are shown in figure 1
for different values of m. Experiments are done over a database of 698 synthetic face im-
ages described by 4096 components that is available at http://isomap.stanford.edu.
Qualitatively similar results have been obtained over other databases such as
Ionosphere (http://www.ics.uci.edu/˜mlearn/MLSummary.html) and swissroll
(http://www.cs.toronto.edu/˜roweis/lle/). Each algorithm generates a two-
dimensional embedding of the images, following the experiments reported for Isomap.
The number of neighbors is 10 for Isomap and LLE, and a Gaussian kernel with a standard
deviation of 0.01 is used for spectral clustering / Laplacian eigenmaps. 95% confidence
intervals are drawn beside each mean difference of error on the figure.
As expected, the mean difference between the two distances is almost monotonically in-
creasing as the fraction of substituted examples grows (x-axis in the figure). In most cases,
the out-of-sample error is less than or comparable to the training set embedding stability:
it corresponds to substituting a fraction of between 1 and 4% of the training examples.
6 Conclusions
In this paper we have presented an extension to five unsupervised learning algorithms
based on a spectral embedding of the data: MDS, spectral clustering, Laplacian eigen-
maps, Isomap and LLE. This extension allows one to apply a trained model to out-of-
sample points without having to recompute eigenvectors. It introduces a notion of function
induction and generalization error for these algorithms. The experiments on real high-
dimensional data show that the average distance between the out-of-sample and in-sample
embeddings is comparable or lower than the variation in in-sample embedding due to re-
placing a few points in the training set.
References
Baker, C. (1977). The numerical treatment of integral equations. Clarendon Press, Oxford.
Belkin, M. and Niyogi, P. (2003). Laplacian eigenmaps for dimensionality reduction and data repre-
sentation. Neural Computation, 15(6):1373–1396.
Bengio, Y., Vincent, P., Paiement, J., Delalleau, O., Ouimet, M., and Le Roux, N. (2003). Spec-
tral clustering and kernel pca are learning eigenfunctions. Technical report, D´ epartement
d’informatique et recherche op´ erationnelle, Universit´
e de Montr´
eal.
Cox, T. and Cox, M. (1994). Multidimensional Scaling. Chapman & Hall, London.
de Silva, V. and Tenenbaum, J. (2003). Global versus local methods in nonlinear dimensionality re-
duction. In Becker, S., Thrun, S., and Obermayer, K., editors, Advances in Neural Information
Processing Systems, volume 15, pages 705–712, Cambridge, MA. The MIT Press.
Gower, J. (1968). Adding a point to vector diagrams in multivariate analysis. Biometrika, 55(3):582–
585.
Koltchinskii, V. and Gin´ e, E. (2000). Random matrix approximation of spectra of integral operators.
Bernoulli, 6(1):113–167.
Ng, A. Y., Jordan, M. I., and Weiss, Y. (2002). On spectral clustering: Analysis and an algorithm.
In Dietterich, T. G., Becker, S., and Ghahramani, Z., editors, Advances in Neural Information
Processing Systems 14, Cambridge, MA. MIT Press.
Roweis, S. and Saul, L. (2000). Nonlinear dimensionality reduction by locally linear embedding.
Science, 290(5500):2323–2326.
Saul, L. and Roweis, S. (2002). Think globally, fit locally: unsupervised learning of low dimensional
manifolds. Journal of Machine Learning Research, 4:119–155.
Schölkopf, B., Smola, A., and Müller, K.-R. (1998). Nonlinear component analysis as a kernel
eigenvalue problem. Neural Computation, 10:1299–1319.
Shawe-Taylor, J. and Williams, C. (2003). The stability of kernel principal components analysis and
its relation to the process eigenspectrum. In Becker, S., Thrun, S., and Obermayer, K., editors,
Advances in Neural Information Processing Systems, volume 15. The MIT Press.
Shi, J. and Malik, J. (1997). Normalized cuts and image segmentation. In Proc. IEEE Conf. Com-
puter Vision and Pattern Recognition, pages 731–737.
Tenenbaum, J., de Silva, V., and Langford, J. (2000). A global geometric framework for nonlinear
dimensionality reduction. Science, 290(5500):2319–2323.
Weiss, Y. (1999). Segmentation using eigenvectors: a unifying view. In Proceedings IEEE Interna-
tional Conference on Computer Vision, pages 975–982.
Williams, C. and Seeger, M. (2000). The effect of the input density distribution on kernel-based
classifiers. In Proceedings of the Seventeenth International Conference on Machine Learning.
Morgan Kaufmann.

You might also like