1 Introduction
Cluster analysis of high dimensional datasets is a core component of unsupervised learning and a common task in many academic settings and practical applications. A widely used practice to more easily visualize the cluster structure present in the data is to first reduce the dimension of data to a lower dimension, typically two. A popular tool to perform this dimensionality reduction is the tdistributed Stochastic Neighborhood Embedding (tSNE) algorithm, introduced by van der Maaten and Hinton [van der Maaten and Hinton(2008)]. tSNE has been empirically shown to preserve local neighborhood structure of points in many applications and the popularity of this method can be seen by the number of citations of the original paper () and implementations in popular packages such as scikitlearn.
The main drawback of tSNE however, is its large computational cost, a big part of which can be written as # of distances computed where is the dimension of the input points. This drawback severely limits its potential use in unsupervised learning problems. To combat the large computational cost of tSNE, many practical developments have been made using techniques such as parallel computation, GPU, and multicore implementations with a large chunk of work on reducing the number of pairwise distances that are computed between the input points [Chan et al.(2019)Chan, Rao, Huang, and Canny, Pezzotti et al.(2019)Pezzotti, Thijssen, Mordvintsev, Höllt, Van Lew, Lelieveldt, Eisemann, and Vilanova, van der Maaten(2014)]. We take a different approach by focusing instead on reducing the value of in the runtime cost.
In this work, we show that the distance computation can be optimized by first projecting the input data into a much smaller random subspace before running tSNE. Our motivation for this approach comes from the field of metric embeddings where it is known that random projections preserve many geometric structures of the input data. For more information, see Section 1.3. More formally, our contributions are the following:

We empirically show that projecting to a very small dimension (even as low as of the original dimension in some cases) and then performing tSNE preserves local cluster information just as well as tSNE with no prior dimensionality reduction step.

We empirically show that performing dimensionality reduction first and then running tSNE is significantly faster than just running tSNE.
We note that our last result is implementation agnostic, since every implementation must compute distances among some of the input points. To show the benefits of our approach and simplify our experiments, we use two implementations of tSNE: a widely available, but slower scikitLearn implementation, and a highly optimized Python implementation called ‘openTSNE’ [Poličar et al.(2019)Poličar, Stražar, and Zupan]. For more details about our experimental setup, see Section 2.1.
1.1 Measuring Quality of an Embedding
We devise an accuracy score to measure the quality of the cluster structure of an embedding. First we note that ideal clusters are ones in which every element has the same label as others in the same cluster. If one has labels for only a few datapoints, this kind of clustering would allow much of the dataset to be correctly labeled. Thus ideally, such clustering would be created without using labels (note that neither random projections nor tSNE use labels to determine embeddings). A datapoint is said to be “correctly clustered” in the lowdimension embedding if it’s label matches that of its nearest neighbor. The accuracy score of an embedding is given by the fraction of datapoints that are correctly clustered. Such a score could be refined by instead considering the modal label of the nearestneighbors. The accuracy score rewards the case that clusters in high dimension stay together in the lower dimension and penalizes the case of different clusters in the higher dimension merging together in the lower dimension since then we can expect the nearest neighbors of many points to have a differing label. In Section 2.2, we compare the accuracy scores of performing dimensionality reduction and then tSNE versus performing only tSNE on various labeled datasets.
1.2 Overview of tSNE
Given a set of points , tSNE first computes the similarity score between and defined as where for a fixed , for some parameter . Intuitively, the value measures the ‘similarity’ between points and . tSNE then aims to learn the lower dimensional points such that if , then
minimizes the Kullback–Leibler divergence of the distribution
from the distribution . For a more detailed explanation of the tSNE algorithm, see [van der Maaten and Hinton(2008)].1.3 Motivation for Using Random Projections
Like tSNE, using a random projection is also a dimensionality reduction tool which has been shown to preserve many geometrical properties of the input data, such as pairwise distances, nearest neighbors, and cluster structures [Dasgupta and Gupta(2003), Indyk and Naor(2007), Makarychev et al.(2019)Makarychev, Makarychev, and Razenshteyn]. One of the key results of this field is the well known Johnson–Lindenstrauss (JL) Lemma which roughly states that given any set of points, a random projection of these points into dimension preserves all pairwise distances upto multiplicative error [Dasgupta and Gupta(2003)]. However, it is not possible to use a random projection to project down to a very small subspace, such as two dimensions used in most applications, while still maintaining the desired geometric properties. This is in contrast to tSNE which has been empirically shown to preserve many local properties of the input data even in very low dimensions (such as two). However, we can leverage advantages of both of these approaches through the counter intuitive idea of using dimensionality reduction before dimensionality reduction. More specifically, we can hope that by first randomly projecting the input data into a smaller dimension, we can preserve enough local information for tSNE to use to be able to meaningfully project the data into two dimensions and still maintain the inherent cluster structure.
Indeed, if we consider the similarity scores computed by tSNE, we see that if a random projection preserves pairwise distances, then the values of the similarity scores remain the same. Furthermore, if we require the weaker condition that the random projection preserves nearest neighbor relations, then we see that the values maintain their order. More precisely, if holds, the similarity scores between points and will be large and thus, tSNE will try to place these points closer together. Using a random projection from to , we immediately get a reduction of the runtime from # of distances computed to # of distances computed . We show the success of our method in Section 2.
1.4 Related Works
There have been many works about improving tSNE through better implementations, such as GPU acceleration or parallel implementations [Chan et al.(2019)Chan, Rao, Huang, and Canny, Pezzotti et al.(2019)Pezzotti, Thijssen, Mordvintsev, Höllt, Van Lew, Lelieveldt, Eisemann, and Vilanova, Ulyanov(2016)]. There has also been work on reducing the number of distances that need to be computed using tree based methods, see [van der Maaten(2014)] for more info. To our knowledge, our work is the first to suggest using random projections in conjunction with tSNE. We have verified this claim by going through the papers that cite the original tSNE paper of [van der Maaten and Hinton(2008)] and searching Google Scholar for papers with the phrase ‘random projection’.
2 Experimental Results
2.1 Experimental Setup and Justification
We construct embeddings by first applying a random projection into
dimensions, then using tSNE to arrive at a two dimensional embedding. The random projections are performed by using an appropriately sized random matrix with i.i.d. Gaussian entries
where is the original dimension of the input data. We repeat this process for several values of exponentially spaced and ranging from to .We use the following four datasets in our experiments: MNIST, KuzushijiMNIST (KMnist) (data set of Japanese cursive characters in the same format as MNIST) [Clanuwat et al.(2018)Clanuwat, BoberIrizar, Kitamoto, Lamb, Yamamoto, and Ha], FashionMNIST (data set of fashion images in the same format as MNIST) [Xiao et al.(2017)Xiao, Rasul, and Vollgraf], and the Small Norb data set (data set of images of toys) [LeCun et al.(2004)LeCun, Huang, and Bottou]. All of our experiments were done in Python using one core of a MacBook Pro using a GHz Intel Core i processor. We only report the time to perform tSNE since the tSNE runtime is many orders of magnitude larger than all the other steps. Our code can be accessed from the following GitHub reprository: https://github.com/ssilwa/optml.
2.2 Results
We first compare the time taken to perform tSNE and the accuracy scores achieved if a dimensionality reduction step is used before using tSNE versus the case where no dimensionality reduction is used. We do so by plotting the ratio of the runtime and accuracy scores. For a given dimension, a higher accuracy score ratio is better and signifies that projecting down to that dimension using a random projection does not deteriorate the performance of tSNE. Likewise, a lower time ratio is better. In Figure 1 we plot the ratio of the accuracy scores and the time taken when we use the openTSNE implementation. The axis is the dimension of the random projection (ranging all the way up to the actual dimension of the input data). In all four datasets, we see that as the dimension increases, both the accuracy ratio and the ratio of the time taken approach . However, we also observe that the accuracy score ratios approach much faster, indicating a ‘’sweet spot” where the dimension is high enough for the random projection to preserve geometric structure, while still low enough for tSNE to run relatively quickly.
Likewise, we show the results of the same experiments using the scikitlearn implementation. Since the scikitlearn implementation is significantly slower than the openTSNE implementation, we subsample the values used and do not test the Small Norb dataset. However, even in this different implementation, we again observe the same trends as in the openTSNE implementation.
In practice, SVD methods such as principal component analysis (PCA) are more widely used than random projections for the general task of dimensionality reduction. We show that for our four datasets, PCA indeed outperforms random projections. That is, we empirically observe that using PCA, rather than a random projection before tSNE, allows us to project to a much smaller dimension while still retaining a high accuracy score ratio, (compared to the case where no dimensionality reduction is used). This is shown in Figure
3 where regardless of the dataset, a projection to a dimension of is sufficient to get an accuracy score ratio close to . An advantage of random projections however, is that it is data oblivious (the dimensionality reduction does not depend on the data) and it has provable guarantees in many cases, such as the JL lemma.References
 [Chan et al.(2019)Chan, Rao, Huang, and Canny] David M Chan, Roshan Rao, Forrest Huang, and John F Canny. Gpu accelerated tdistributed stochastic neighbor embedding. Journal of Parallel and Distributed Computing, 131:1–13, 2019.
 [Clanuwat et al.(2018)Clanuwat, BoberIrizar, Kitamoto, Lamb, Yamamoto, and Ha] Tarin Clanuwat, Mikel BoberIrizar, Asanobu Kitamoto, Alex Lamb, Kazuaki Yamamoto, and David Ha. Deep learning for classical japanese literature, 2018.
 [Dasgupta and Gupta(2003)] Sanjoy Dasgupta and Anupam Gupta. An elementary proof of a theorem of johnson and lindenstrauss. Random Struct. Algorithms, 22(1):60–65, January 2003. ISSN 10429832. doi: 10.1002/rsa.10073. URL http://dx.doi.org/10.1002/rsa.10073.
 [Indyk and Naor(2007)] Piotr Indyk and Assaf Naor. Nearestneighborpreserving embeddings. ACM Trans. Algorithms, 3(3), August 2007. ISSN 15496325. doi: 10.1145/1273340.1273347. URL http://doi.acm.org/10.1145/1273340.1273347.

[LeCun et al.(2004)LeCun, Huang, and Bottou]
Yann LeCun, Fu Jie Huang, and Léon Bottou.
Learning methods for generic object recognition with invariance to
pose and lighting.
In
Proceedings of the 2004 IEEE Computer Society Conference on Computer Vision and Pattern Recognition
, CVPR’04, pages 97–104, Washington, DC, USA, 2004. IEEE Computer Society. URL http://dl.acm.org/citation.cfm?id=1896300.1896315. 
[Makarychev et al.(2019)Makarychev, Makarychev, and
Razenshteyn]
Konstantin Makarychev, Yury Makarychev, and Ilya Razenshteyn.
Performance of johnsonlindenstrauss transform for kmeans and kmedians clustering.
InProceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing
, STOC 2019, pages 1027–1038, New York, NY, USA, 2019. ACM. ISBN 9781450367059. doi: 10.1145/3313276.3316350. URL http://doi.acm.org/10.1145/3313276.3316350.  [Pezzotti et al.(2019)Pezzotti, Thijssen, Mordvintsev, Höllt, Van Lew, Lelieveldt, Eisemann, and Vilanova] N. Pezzotti, J. Thijssen, A. Mordvintsev, T. Höllt, B. Van Lew, B. P. F. Lelieveldt, E. Eisemann, and A. Vilanova. Gpgpu linear complexity tsne optimization. IEEE Transactions on Visualization and Computer Graphics, pages 1–1, 2019. doi: 10.1109/TVCG.2019.2934307.
 [Poličar et al.(2019)Poličar, Stražar, and Zupan] Pavlin G. Poličar, Martin Stražar, and Blaž Zupan. opentsne: a modular python library for tsne dimensionality reduction and embedding. bioRxiv, 2019. doi: 10.1101/731877. URL https://www.biorxiv.org/content/early/2019/08/13/731877.
 [Ulyanov(2016)] Dmitry Ulyanov. Multicoretsne. https://github.com/DmitryUlyanov/MulticoreTSNE, 2016.

[van der Maaten(2014)]
Laurens van der Maaten.
Accelerating tsne using treebased algorithms.
Journal of Machine Learning Research
, 15:3221–3245, 2014. URL http://jmlr.org/papers/v15/vandermaaten14a.html.  [van der Maaten and Hinton(2008)] Laurens van der Maaten and Geoffrey Hinton. Visualizing data using tSNE. Journal of Machine Learning Research, 9:2579–2605, 2008. URL http://www.jmlr.org/papers/v9/vandermaaten08a.html.
 [Xiao et al.(2017)Xiao, Rasul, and Vollgraf] Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashionmnist: a novel image dataset for benchmarking machine learning algorithms, 2017.
Comments
There are no comments yet.