# Supervised Dimensionality Reduction and Visualization using Centroid-encoder

## Abstract

Visualizing high-dimensional data is an essential task in Data Science and Machine Learning. The Centroid-Encoder (CE) method is similar to the autoencoder but incorporates label information to keep objects of a class close together in the reduced visualization space. CE exploits nonlinearity and labels to encode high variance in low dimensions while capturing the global structure of the data. We present a detailed analysis of the method using a wide variety of data sets and compare it with other supervised dimension reduction techniques, including NCA, nonlinear NCA, t-distributed NCA, t-distributed MCML, supervised UMAP, supervised PCA, Colored Maximum Variance Unfolding, supervised Isomap, Parametric Embedding, supervised Neighbor Retrieval Visualizer, and Multiple Relational Embedding. We empirically show that centroid-encoder outperforms most of these techniques. We also show that when the data variance is spread across multiple modalities, centroid-encoder extracts a significant amount of information from the data in low dimensional space. This key feature establishes its value to use it as a tool for data visualization.

Data Science, Machine Learning, supervised dimension reduction, centroid-encoder, autoencoder, variance

## 1 Introduction

Visualization of data is the process of mapping points in dimensions greater than three down to two or three dimensions, providing a window into high-dimensions so that they can be seen and interpreted. The ability to see in high-dimensions can assist data explorers in many ways, including the identification of experimental batch effects, data separability, and class structure. Principal component analysis [46, 25] continues to be one of the most widely used methods for data visualization over one hundred years after its initial discovery [29]. Nonetheless, PCA often produces ambiguous results, in some cases collapsing distinct classes into overlapping regions in the setting where class labels are available. It is tempting to incorrectly infer from this that the data is not separable, even nonlinearly, in higher dimensions.

Nonlinear extensions to PCA were originally introduced to address the limitations of optimal linear mappings [36, 37, 45], also see [33] for additional early references and details. These papers provided the first applications of autoencoder neural networks where data sets are nonlinearly mapped to themselves. This is accomplished by first unfolding them in higher dimensions before passing through a bottleneck layer of a reduced dimension where data visualization is typically done. In the process of nonlinear dimension reduction, novel latent or hidden features which are an amalgamation of the observables, may be discovered. A theoretical insight into these algorithms is provided by Whitney’s theorem from differential geometry that connects autoencoders to manifold learning [7, 8]. Fundamental innovations were proposed to these ideas in the setting of deep networks that made their application far more effective [22, 23].

The development of tools for data visualization is predicated by the design of the objective function and whether it incorporates class label information, i.e., is it supervised or unsupervised. The objective function encodes the goals of the dimension reduction, i.e., what important information about the data is to be captured. This might be geometric or topological structure (shape), neighborhood relationships, or descriptive statistics such as class distribution data when data class labels are available.

This paper concerns the integration of label information to the nonlinear autoencoder reduction process for the purposes of data visualization. Here we develop and comparatively evaluate this centroid-encoder (CE) algorithm designed for the analysis of labeled data. While standard autoencoders map the identity on points, centroid-encoders map points to their centroids while passing through a low-dimensional representation. This approach serves to provide a low-dimensional encoding for visualization while ensuring that elements with the same label retain their class structure. The smoothness of mapping functions ensures that a similar behavior is captured at the centroid-encoder bottleneck layer.

In this paper, we analyze centroid-encoder and compare its performance with other methods. The article is organized as follows: In Section 2, we review related work, both supervised and unsupervised. In Section 3, we discuss the autoencoder neural network for nonlinear data reduction. In Section 4, we present modifications to the autoencoder that result in centroid encoding. In Section 5, we present the training algorithm employed in this paper. In Section 6, we illustrate the application of CE to a range of bench-marking data sets taken from the literature. In Section 7, we analyze these results and conclude in Section 8.

## 2 Related Work

Data reduction for visualization has a long history and remains an area of active research. We describe the literature relating to unsupervised and supervised methods where we assume data class labels are unavailable and available, respectively.

### 2.1 Unsupervised Methods

Principal Components Analysis is often the first (and last) tool used for visualization of unlabeled data and is designed to retain as much of the statistical variance as possible [46, 25], see also [28]. Equivalently, PCA minimizes mean-square approximation error as well as Shannon’s entropy [61]. Self-organizing mappings (SOMs) learn nonlinear topology-preserving transformations that map data points to centers that are then mapped to the center indices. SOMs have been widely used in data visualization, having been cited over 20,000 times since their introduction [34].

Another class of methods uses interpoint distances as the starting point for data reduction and visualization. For example, Multidimensional Scaling is a spectral method that computes a point configuration based on the computation of the eigenvectors of a doubly centered distance matrix [56]. The goal of the optimization problem behind MDS is to determine a configuration of points whose Euclidean distance matrix is optimally close to the prescribed distance matrix. A related approach, known as Isomap, applies MDS to approximate geodesic distances computed numerically from data on a manifold [55]. Laplacian eigenmaps is another popular spectral method that uses distance matrices to reduce dimension and conserve neighborhoods [4]. These spectral methods belong to a class of techniques referred to as manifold learning algorithms; see also locally linear embedding [50], stochastic neighbor embedding [21], and maximum variance unfolding [62].

The technique t-distributed stochastic neighbor embedding [57], an extension of SNE, was developed to overcome the data crowding or clumping problem often observed with manifold learning methods and is currently a popular method for data visualization. More recently, the uniform manifold approximation and projection (UMAP) algorithm has been proposed, which uses Riemannian geometry and fuzzy simplicity sets to create a low-dimensional and locally uniformly distributed embedding of the data [41]. It has been reported that the algorithm has a better run time than t-SNE and offers compelling visualizations.

Note that these spectral methods including MDS, Laplacian Eigenmaps and UMAP compute embeddings based on solving an eigenvector problem requiring the entire data set. Such methods do not actually create mappings that can be applied to reduce the dimension of new data points without repeating the computation or resorting to the use of landmarks [12]. This, in contrast to methods such as PCA, SOM and autoencoders that serve as mappings for streaming data.

### 2.2 Supvervised Methods

Fisher’s linear discriminant analysis (LDA) reduces the dimension of labeled data by simultaneously optimizing class separation and within-class scatter [15, 14]. Both LDA and PCA are linear methods in that they construct optimal projection matrices, i.e., linear transformations for reducing the dimension of the data.

It is, in general, possible to add labels to unsupervised methods to create their supervised analogues. A heuristic-based supervised PCA model first selects important features by calculating correlation with the labels and then applies standard PCA of the chosen feature set [1]. Another supervised PCA technique, proposed by Barshan et al. [3], uses a Hilbert-Schmidt independence criterion to compute the principal components which have maximum dependence on the labels. Colored maximum variance unfolding [53], which is the supervised version of MVU, is capable of separating different new groups better than MVU and PCA.

The projection of neighborhood component analysis [18] produces a better coherent structure in two-dimensional space than PCA on several UCI data sets. Parametric embedding [27], which embeds high-dimensional data by preserving the class-posterior probabilities of objects, separates different categories of Japanese web pages better than MDS. Optimizing the NCA objective on a pre-trained deep architecture, Salakhutdinov et al. [52] achieved error rate on MNIST test data with 3-nearest neighbor classifier on 30-dimensional feature space. Min et al. proposed to optimize the NCA and maximally collapsing metric learning [17] objective using a Student t-distribution on a pre-trained network [43]. Their approach yielded promising generalization error using a 5-nearest neighbor classifier on MNIST and USPS data on two-dimensional feature space. Neighbor retrieval visualizer [59] optimizes its cost such that the similar objects are mapped close together in embedded space. Its supervised variant uses the class information to produce the low dimensional embedding. NeRV and its supervised counterpart were reported to outperform some of the state-of-the-art dimension reduction techniques on a variety of datasets.

Supervised Isomap [9], which explicitly uses the class information to impose dissimilarity while configuring the neighborhood graph on input data, has a better visualization and classification performance than Isomap. A supervised method using Local Linear Embedding has been proposed by [64]. [48] have suggested a
Laplacian eigenmap based supervised dimensionality reduction technique. Stuhlsatz et al. proposed a generalized discriminant analysis based on classical LDA [54], which is built on deep neural network architecture. Min et al. proposed a shallow supervised dimensionality reduction technique where the MCML objective is optimized based on some learned or precomputed exemplars [44].
Although UMAP is originally presented as an unsupervised technique, its software package includes the option to build a supervised model ^{1}

Autoencoder neural networks are the starting point for our approach and are described in the next section. In a preliminary biological application, centroid-encoder (CE) was used to visualize the high-dimensional pathway data [16].

## 3 Autoencoder Neural Networks

An autoencoder is a dimension reducing mapping that has been optimized to approximate the identity on a set of training data [35, 33, 5]. The mapping is modeled as the composition of a dimension reducing mapping followed by a dimension increasing reconstruction mapping , i.e.,

where the encoder is represented

and the decoder is represented

The construction of and , and hence , is accomplished by solving the unconstrained optimization problem

(1) |

for a given set of points . Hence, the autoencoder learns a function such that where is the set of model parameters that is found by solving the optimization problem. The encoder map takes the input and maps it to a latent representation

In this paper we are primarily concerned with visualization so we take . The decoder ensures that the encoder is faithful to the data point, i.e., it serves to reconstruct the reduced point to its original state

The parameters are learned by using error backpropagation [51, 63]. The details for using multi-layer perceptrons for training autoencoders can be found in [33].

If we restrict and to be linear transformations then [2] showed that autoencoder function learns the same subspace of PCA. The nonlinear autoencoder has been proposed as a nonlinear version of PCA [36, 37]. If we restrict to be linear and allow to be nonlinear then the autoencoder fits into the blueprint of Whitney’s theorem for manifold embeddings [7, 8]. Topologically sensitive nonlinear reduction use, e.g., topological circle or sphere encoding neurons [32, 31, 26] to capture shape in data. The use of shallow architectures was partly motivated by the theoretical result that a neural network with one hidden layer is a universal approximator by [24, 10].

A probabilistic pre-training approach, known as Restricted Boltzmann Machine (RBM), was introduced [23, 22], which initializes the network parameters near to a good solution followed by a nonlinear refinement to further fine-tune the parameters. This break-through opened the window of training neural networks with many hidden layers. Since then deep neural networks (DNN) architecture has been employed to train autoencoders. The pre-training approach was extended further to continuous values by [5, 6]. Several other deep autoencoder based model were also proposed to extract sparse features [49, 38]. The method of denoising autoencoder [60] was introduced to learn latent features by reconstructing an input from it noisy version. Autoencoders can also be trained by stacking multiple convolutional layers as described by [40, 20, 11]. A comprehensive description of autoencoders and their variants can be found in [19, chap. 14].

## 4 The Centroid-Encoder

The autoencoder neural network does not employ any label information related to the classes of the data. Here we propose a form of supervised autoencoder that exploits label information. The centroid-encoder (CE) is trained by mapping data through a neural network with the architecture of an autoencoder, but the learning target of any point is not that actual point, rather the mean of points in the associated class. So CE does not map the identity, now the target points in the image of the map are the centroids of the data in the ambient space. Centroid-encoder is a nonlinear parametric map ( where is the set parameters) which minimizes the within-class variance by mapping all the samples of a class/category to its centroid.

### 4.1 Centroid-Encoder Backpropagation

Consider an -class data set with classes denoted where the indices of the data associated with class are denoted . We define centroid of each class as

is the cardinality of class . The centroid-encoder is trained by determining a mapping with input-output pairs

where is the target center for data point , i.e., . Thus, unlike autoencoder, which maps each point to itself, centroid-encoder will map each point to its class centroid

while passing the data through a bottleneck layer of dimension to provide the reduced point . The cost function of centroid-encoder is defined as

(2) |

This cost is also referred to as the distortion error ([39]). The network parameters () are trained using the error backpropagation appropriately modified for the centroid targets. We can connect this to the learning procedure for autoencoders by first writing

where the is identical for autoencoders and centroid-encoders. Then, applying the chain rule, we have

where the term is the same as for autoencoders and is the th component of the parameter vector . The new term is readily calculated to be

(3) |

## 5 The Training Algorithm

The training is very similar to that of an autoencoder and the steps are described in Algorithm 1. As with autoencoders, the centroid-encoder is a composition of two maps . For visualization, we train a centroid-encoder network using a bottleneck architecture, meaning that the dimension of the image of the map is 2 or 3.

### 5.1 Pre-training Centroid-encoder

Here we describe the pre-training strategy of centroid-encoder. We employ a technique we refer to as pre-training with layer-freeze, i.e., pre-training is done by adding new hidden layers while mapping samples of a class to its centroid; see Figure 1. In this approach, weights of hidden layers are learned sequentially. The algorithm starts by learning the parameters of the first hidden layer using standard backpropagation. Then the second hidden layer is added in the network with weights initialized randomly. At this point, the associated parameters of the first hidden layer are kept frozen. Now the weights of the second hidden layer are updated using backpropagation. We repeat this step until pre-training is done for each hidden layer. Once pre-training is complete, we do an end-to-end fine-tuning by updating the parameters of all the layers at the same time. It’s noteworthy that our pre-training approach is different than the greedy layer-wise pre-training proposed by [23] and [5, 6]. The unsupervised pre-training of Hinton et al. and Bengio et al. uses the activation of the hidden layer as the input for the layer. In our approach, we used the original input-output pair to pre-train each hidden layer. As we use the labels to calculate the centroids , so our pre-training is supervised. In the future, we would like to explore the unsupervised pre-training in the setup of centroid-encoder.

## 6 Classification and Visualization Experiments

We select three suites of data sets from the literature with which we conduct three bench-marking experiments comparing centroid-encoder with a range of other supervised dimension reduction techniques. We describe the details of the data sets in Section 6.1. In Section 6.2, we describe the comparison methodology and present the results of the experiments in Section 6.3.

Experiment 1: The first bench-marking experiment is conducted on the widely studied MNIST and USPS data sets (see Section 6.1 for details). In this experiment we compare CE with the following methods: autoencoder, nonlinear NCA [52], supervised UMAP [41], GerDA [54], HOPE [44], parametric t-SNE [58], t-distributed NCA [43] and t-distributed MCML [43], and supervised UMAP. Parametric t-SNE is a DNN based model with RBM pre-training, where the objective of t-SNE is used to update the model parameters (hence parametric t-SNE). Although it is an unsupervised method, we included it as t-SNE has become a baseline model to compare visualization. We also included autoencoder as it is widely used for data visualization. We implemented nonlinear-NCA in Python, and we used the scikit-learn [47] package to run supervised UMAP. For the rest of the methods, we took the published results for comparison.

Experiment 2: We conducted the second experiment on Phoneme, Letter, and Landsat data sets (see Section 6.1 for details). In this case, we compared CE with the following techniques: supervised neighbor retrieval visualizer (SNeRV) by [59], multiple relational embedding (MRE) by [42], colored maximum variance unfolding (MUHSIC) by [53], supervised isomap (S-Isomap) by [9], parametric embedding (PE) by [27] and neighborhood component analysis (NCA) by [18]. We didn’t implement these models; instead, we used the published results from [59]. On the Landsat data set, we ran UMAP and SUMAP along with the methods as mentioned above.

Experiment 3: For the third experiment, we compared the performance of centroid-encoder with supervised PCA (SPCA), and kernel supervised PCA (KSPCA) on the Iris, Sonar, and a subset of USPS dataset (details of these dataset are given in Section 6.1). We implemented SPCA and KSPCA in Python following [3].

### 6.1 Data Sets

Here we provide a brief description of the data sets used in the bench-marking experiments.

MNIST Digits: This is widely used collection of digital images of handwritten digits (0..9)^{2}

USPS Data: A data set of handwritten digits ()^{3}

Phoneme Data: This data set is created from Finish speech recorded continuously from the same speaker. A 20-dimensional vector represents each phoneme. The data set consists of 3924 number of samples distributed over 13 classes. The data set is taken from the LVQ-PAK^{4}

Letter Recognition Data: Available in the UCI Machine Learning Repository [13], this data set is comprised of 20,000 samples where each element represents an upper case letter of the English alphabet A to Z selected from twenty different fonts. Each sample is randomly distorted to produce a unique representation that is converted to 16 numerical values and 26 classes.

Landsat Satellite Data: This data set consists of satellite images with four different spectral bands. Given the pixel values of a 3x3 neighborhood, the task is to predict the central pixel of each 3x3 region. Each sample consists of 9-pixel values from 4 different bands, which makes the dimension 36. There are six different classes and 6435 samples. The data set is also available in UCI Machine Learning Repository [13].

Iris Data: The UCI Iris data set [13] is comprised of three classes and is widely used in the Machine Learning literature. Each class has 50 samples and, each sample has four features.

Sonar Data: This UCI data set [13] has two classes: mine and rock. Each sample is represented by a 60 dimensional vector. The mine class has 111 patterns, whereas the rock category has 97 samples.

In the next section we describe the methodology used to compare the low-dimensional embedding of CE with other methods on the data sets described above.

### 6.2 Methodology

To objectively compare the performance of CE with other techniques in the literature, we employ
a standard class prediction error
on the two-dimensional visualization domain.^{5}

The class prediction error is defined as

(4) |

Here is total number of test samples, is the true label of the test sample, and is a classification function which returns the predicted label of the embedded test sample . Here denotes the indicator function, which has the value 1 if the argument is true (label incorrect), and 0 otherwise (label correct).

A common choice of for bench-marking algorithms in the supervised visualization literature is the -nearest neighbor (k-NN) classifier [18, 59, 58, 43]. Thus, the evaluation proceeds as follows: for each method divide the data into training and testing sets; train the model on the training set and then map the test set through the trained model to get the low dimensional (2D) representation. Finally, classify each test point in the 2D visualization space by k-NN algorithm. The prediction error indicates the percentage of wrongly classified samples on the test data and is an objective measure of the quality of the visualization. A low error rate suggests that the samples from the same class are close together in the visualization space.

Like autoencoder, centroid-encoder is a model based on deep architecture whose performance varies based on network topology. In addition to network architecture, both the models require the following hyper-parameters: learning rate^{6}^{7}^{8}

The supervised UMAP (S-UMAP) and nonlinear NCA (NNCA), also require the tuning of hyper-parameters. For NNCA, we used the architecture input dimension as proposed by [43]; we also followed the same pre-training and fine-tuning steps described there.
The algorithm S-UMAP requires two hyper-parameters including, the number of neighbors (^{9}^{10}

On Phoneme, Letter, and Landsat data, our experimental setup is similar to that of [59]. We randomly selected 1500 samples from each dataset and ran 10-fold cross-validation. We picked the hyper-parameters (network architecture, learning rate, mini-batch size, weight decay) by running 10-fold internal cross-validation on the training set. After choosing the model parameters, we trained the model with the full training data and calculated the error rate using -NN (=5) on the holdout test set. Once all the 10 test sets are evaluated, we reported the average test error with standard deviation.

Dataset | Dimensionality | No. of Classes | No. of Training | No. of Test |
---|---|---|---|---|

Samples | Samples | |||

MNIST | 784 | 10 | 60,000 | 10,000 |

USPS | 256 | 10 | 8000 | 3000 |

Phoneme | 20 | 13 | 1,350 | 150 |

Letter | 16 | 26 | 1,350 | 150 |

Landsat | 36 | 6 | 1,350 | 150 |

Iris | 4 | 3 | 105 | 45 |

Sonar | 60 | 2 | 146 | 62 |

USPS 1000 | 256 | 10 | 700 | 300 |

We followed the experimental setup of [3] in the last experiment, where we compared centroid-encoder with supervised PCA (SPCA) and kernel supervised PCA (KSPCA). Each of the three data sets (Iris, Sonar, USPS) is split randomly into training and test by the ratio of 70:30. After training the models, the generalization error is calculated on the test set using -NN (=5). We repeat the experiment 25 times and report the average error with the standard deviation for all three data sets. For the USPS set, we randomly picked 1000 cases and used that subset for our experiment, as done by [3]. Among the three models, centroid-encoder and KSPCA require hyper-parameters. For KSPCA we apply RBF kernel on data and delta kernel on labels, as recommended by Barshan et al. The delta kernel doesn’t require any parameter, whereas the RBF kernel needs the parameter (width of the Gaussian^{11}

Dataset | Network topology | Activation | Learning | Batch | Weight |
---|---|---|---|---|---|

function | rate | size | Decay | ||

MNIST | tanh | 0.0008 | 512 | 2e-5 | |

USPS | relu | 0.001 | 64 | 2e-5 | |

Phoneme | relu | 0.01 | 50 | 2e-5 | |

Letter | relu | 0.01 | 50 | 5e-5 | |

Landsat | relu | 0.01 | 50 | 5e-5 | |

Iris | relu | 0.001 | 16 | 2e-5 | |

Sonar | relu | 0.001 | 16 | 2e-5 |

To train CE with an optimal number of epochs, we used of training samples as a validation set in all of our visualization experiments. We measure the generalization error on the validation set after every training epochs. Once the validation error doesn’t improve, we stop the training. Finally, we merge the validation set with the training samples and train the model for additional epochs. The model parameters are updated using Adam optimizer ([30]). Table 2 gives the details of network topology and hyper-parameters used in training of CE. We have implemented centroid-encoder in PyTorch to run on GPUs. The implementation is available at: https://github.com/Tomojit1/Centroid-encoder/tree/master/GPU.

In addition to computing the prediction error, we also visualize the two-dimensional embedding of test samples of each model. For centroid-encoder, we plot the bottleneck output of training and test data using Voronoi regions. Here, the bottleneck outputs of training data are used to compute the centroids of each class, which are used to create the Voronoi cells. The test set was then mapped to the reduced space. This visualization approach allows one to see the quality of the CE classification directly.

### 6.3 Quantitative and Visual Analysis

Now we present the results from a comprehensive quantitative and qualitative analysis across diverse data sets. Note that the primary objective of our assessment is to determine the quality of information obtained from visualization, including class separability, data scatter, and neighborhood structure. Since this assessment is by its very nature subjective, we also employ label information to determine classification rates that provide additional insight into the data reduction for visualization. Computational expense is also an essential factor, and we will see that this is a primary advantage of CE over other methods when the visualizations and error rates are comparable.

#### Mnist

As shown in Tables 3 (results with pre-training) and 4 (results without pre-training), the models with relatively low error rates for the MNIST data amongst our suite of visualization methods are dt-MCML, dG-MCML, centroid-encoder, and HOPE. The error rate of CE is comparable to the top-performing model dt-MCML and superior to NNCA and supervised UMAP by a margin of and , respectively. Note that methods in the MCML and NCA families require the computation of distance matrix over the data set, making them significantly more expensive than CE, which only requires distance computations between the data of a class and its center. It’s noteworthy that the error of CE is lower than the other non-linear variants of NCA: dt-NCA and dG-NCA. Among all the models, parametric t-SNE (pt-SNE) and autoencoder exhibit the worst performance with error rates on MNIST data are and , respectively. These high error rates are not surprising given these methods do not use label information.

The prediction error of CE with pre-training is relatively low at , as shown in Table 3 behind the more computationally expensive dt-MCML and dG-MCML algorithms. With no pre-training, the numeric performance of centroid-encoder is statistically equivalent to dt-MCML and HOPE.

Method | Dataset | |
---|---|---|

MNIST | USPS | |

Centroidencoder | ||

Supervised UMAP | ||

NNCA | ||

Autoencoder | ||

dt-MCML | 2.03 | |

dG-MCML | ||

GerDA | NA | |

dt-NCA | ||

dG-NCA | ||

pt-SNE | NA |

Method | Dataset | |
---|---|---|

MNIST | USPS | |

Centroidencoder | ||

Autoencoder | ||

HOPE | ||

dt-MCML | ||

dt-NCA |

While the prediction error is essential as a quantitative measure, the visualizations reveal information not encapsulated in this number. The neighborhood relationships established by the embedding provide potentially valuable insight into the structure of the data set. The two-dimensional centroid-encoder visualization of the MNIST training and test sets are shown in Figure 2. The entire 10,000 test samples are shown in b) while only a subset of the training data set, 1000 digits picked randomly from each class, is shown in a). The separation among the ten classes is easily visible in both training and test data, although there are few overlaps among the categories in test data. Consistent with the low error rate, the majority of the test digits are assigned to the correct Voronoi cells.

Now let’s consider the visualization from a neighborhood relationship perspective. We compare the results with those of Laplacian Eigenmaps (LE), as shown in Figure 3, an unsupervised manifold learning spectral method that solves an optimization problem preserving neighborhood relations [4]. Both CE and LE place digits 5 and 8 as neighbors at the center, allowing us to view all digits as being perturbations of these numbers. Digits 7, 9, and 4 are collapsed to one region; in contrast, CE is built to exploit label information and separates these neighboring digits. LE clumps 7, 9, 4 next to 1 as well, consistent with the CE visualization. The digit 0 neighbors 6 for both CE and LE, but LE significantly overlaps the 6 with the digit 5.

Figure 4 shows the two-dimensional arrangement of 10,000 MNIST test set digits using nonlinear NCA, supervised UMAP, UMAP, autoencoder, and t-SNE. It is apparent that CE is more similar to LE in terms of the relative positioning of the digits in 2D than these other supervised visualization methods. There are some similarities across all the models, e.g., 0 and 6 are neighbors for all methods (except for SUMAP), as are the digits 4, 9, and 7. The separation among the different digit groups more prominent in CE than all the methods save for SUMAP, but as seen above, quantitatively, SUMAP has a higher error rate than CE. We note that unsupervised UMAP, as well as t-SNE, both agree with CE that the digits 5 and 8 should be in the center. However, in contrast, CE provides a mapping that can be applied to streaming data.

#### Usps

On USPS, centroid-encoder without pre-training has a prediction error slightly lower than HOPE but outperformed dt-MCML and dt-NCA by the margins of and , respectively. Without pre-training, the centroid-encoder performed better than NNCA with pre-training and supervised-UMAP on both MNIST and USPS datasets.

On the USPS data, the top three models with pre-training are dt-MCML, centroid-encoder, and dG-MCML with the error rates of 2.46, 2.91, and 3.37, respectively. The error rate of centroid-encoder is better than NNCA and supervised-UMAP by a margin of and , respectively. Like in MNIST, dt-NCA and dG-NCA performed relatively poorly compared to centroid-encoder. Again, autoencoder performed the worst among all the models.

In Figure 5, we show the two-dimensional visualization of 3,000 test samples using nonlinear NCA, supervised UMAP, centroid-encoder, and autoencoder. Like MNIST, the neighborhoods of CE and the other methods share many similarities. Digits 4, 9, and 7 are still neighbors in all the techniques but now sit more centrally. Digits 8 and 6 are now consistently neighbors across all methods. The within-class scatter of each digit is again the highest for autoencoder since it is unsupervised. Nonlinear NCA also has considerable variance across all the digit classes. Supervised UMAP has tighter clumping of the classes – apparently an integral feature of SUMAP as well as UMAP. However, supervised UMAP has some misplaced digits compared to CE, which is evident from the error rate in Table 3. These observations are consistent with MNIST visualizations. SUMAP emphasizes the importance of local structure over the global structure of the data. In contrast to CE, Autoencoder doesn’t provide any meaningful information about the neighborhood structure.

#### Letter, Landsat and Phoneme Data Sets

Here we compare centroid-encoder with another suite of supervised methods including, SNeRV, PE, S-Isomap, MUHSIC, MRE, and NCA. Table 5 shows the results on three benchmarking data sets, including UCI Letter, Landsat, and Phoneme dataset. On Landsat data, we include UMAP and SUMAP for additional comparison. CE produces the smallest prediction error on Landsat and Phoneme data sets and is ranked second on the Letter data set. On Landsat dataset, the top three models are CE, SUMAP and UMAP. On the Phoneme dataset, the centroid-encoder outperforms the second-best model, which is S-Isomap, by a margin of . Notably, the variance of errors of centroid-encoder () is better than the S-Isomap (). On the Letter dataset, the centroid-encoder achieves the error rate of , which is the second-best model after SNeRV (), although the variance of the result of centroid-encoder is better than SNeRV by a margin of . It’s also noteworthy that the variance of errors for centroid-encoder is the lowest in every case.

Method | Dataset | ||
---|---|---|---|

Letter | Landsat | Phoneme | |

CE | |||

SUMAP | NA | NA | |

UMAP | NA | NA | |

SNeRV | |||

SNeRV | |||

PE | |||

S-Isomap | |||

NCA | |||

MUHSIC | |||

MRE |

The visualization of the two-dimensional embedding using centroid-encoder on Landsat is shown in Figure 6. We might conclude that the water content in the samples is causing scatter in the 2D plots and decreases as we proceed counter-clockwise. The test samples encode essentially the same structure. In Figure 7, we show the visualization using SUMAP. We see tighter clusters, but there is no difference between the damp and non-damp soil types. The neighborhood relationships, demonstrated by Laplacian Eigemaps, also show this transition by dampness consistent with CE. Damp and very damp soils are, however, not neighbors using SUMAP, making the visualization less informative.

#### Iris, Sonar and USPS (revisited) Data Sets

In our last experiment, we compare supervised PCA and kernel supervised PCA to centroid-encoder. Table 6 contains the classification error using a 5-NN classifier, showing that centroid-encoder outperforms SPCA and KSPCA by considerable margins by this objective measure.

In the top row of Figure 8, we present the two-dimensional visualization of Iris test data. Among the three methods, centroid-encoder and KSPCA produce better separation compared to SPCA. SPCA can’t separate the Iris plants Versicolor and Virginica in 2D space. The dispersion of the three Iris categories is relatively higher in KSPCA and SPCA compared to centroid-encoder. Surprisingly in KSPCA, three classes are mapped on three separate lines.

The two-dimensional visualization of Sonar test samples is shown in the middle row of Figure 8. None of the methods can completely separate the two classes. The embedding of KSPCA is slightly better than SPCA, which doesn’t separate the data at all. In centroid-encoder, the two classes are grouped relatively far away from each other. Most of the rock samples are mapped at the bottom-left of the plot, whereas the mine samples are projected at the top-right corner.

The visualization of USPS test data is shown at the bottom of Figure 8. Both SPCA and KSPCA are unable to separate the ten classes, although KSPCA separates digit 0s from the rest of the samples. In contrast, the centroid-encoder puts the ten digit-classes in 2-D space without much overlap. Qualitatively, the embedding of centroid-encoder is better than the other two.

Method | Dataset | ||
---|---|---|---|

IRIS | Sonar | USPS | |

Centroidencoder | |||

KSPCA | |||

SPCA |

## 7 Discussion and Analysis of Results

The experimental results in Section 6.3 establish that centroid-encoder performs competitively, i.e., it is the best, or near the best, on a diverse set of data sets. The algorithms that produce similar classification rates require the computation of distance matrices and are hence more expensive than centroid-encoders. Here we analyze the CE algorithm in more detail to discover why this improved performance is perhaps not surprising. This has to do, at least in part, with the fact that centroid-encoder, implementing a nonlinear mapping, is actually able to capture more variance than PCA, and this is particularly important in lower dimensions.

### 7.1 Variance Plot to Explain the Complexity of Data

PCA captures the maximum variance over the class of orthogonal transformations [33]. The total variance captured as a function of the number of dimensions is a measure of the complexity of a data set. We can use variance to establish, e.g., that the digits 0 and 1 are less complex than the digits 4 and 9. To this end, we use two subsets from the MNIST training set: the first one contains all the digits 0 and 1, and the second one has all the digits 4 and 9. Next, we compute the total variance captured as a function of dimension; see Figure 9. Clearly, the variance is more spread out across the dimensions for the digits 4/9. In Figure 10, we show the visualization of these two subsets using PCA. We see that the 0/1 samples in subset1 are well separated in two-dimensional space, whereas the data in subset2 are clumped together. This lies in the fact that in low dimension (2D) PCA captures more variance from subset1 (around 41%) as compared to subset2 (about 22%). We can say that subset2 is more complex than subset1.

### 7.2 Centroid-encoder and Variance

In this section, we demonstrate how centroid-encoder maps a higher fraction of the variance of the data to lower dimensions. Again, consider the subset of digits 4 and 9 from the experiment above. We use all the digits 4 and 9 from the MNIST test set as a validation set. We trained a centroid-encoder with the architecture where we used hyperbolic tangent (‘tanh’) as the activation function. We keep the number of nodes the same in all the three layers. After the training, we pass the training and test samples through the network and capture the hidden activation which we call CE-transformed data. We show the variance plot and the two-dimensional embedding by PCA on the CE-transformed data. Figure 11 compares the variance plot between the original data and the CE-transformed data. In the original data, only 22% of the total variance is captured, whereas about 89% of the total variance is captured in CE-transformed data. It appears that the nonlinear transformation of centroid-encoder puts the original high dimensional data in a relatively low dimensional space. Visualization using PCA of CE-transformed data (both training and test) is shown in Figure 12. This time, PCA separates the classes in two-dimensional space. Comparing Figure 12 with Figure 9(b), it appears that the transformation by centroid-encoder is helpful for low dimensional visualizations.

### 7.3 Computational Complexity and Scalability

The computational complexity of the centroid-encoder is effectively the same as the autoencoder. The advantage of centroid-encoder over many other data visualization techniques is that it is not necessary to compute pairwise distances. If everything else is fixed, we can view centroid-encoder as scaling linearly with the number of data points. Techniques that require distance matrices scale quadratically with the number of data points and can be prohibitively slow as the data set size increases. Methods based on distance matrices include NNCA, dt-NCA, dG-NCA, dt-MCML, and dG-MCML, as well as the spectral methods including MDS, UMAP, Laplacian Eigenmaps, Isomap and their supervised counterparts. The only overhead of centroid-encoder is the calculation of centroids of each class, but this is also linear with the number of classes.

## 8 Conclusion

In this paper, we presented the centroid-encoder for the task of data visualization when class labels are available. We compared CE to state-of-the-art techniques and showed advantages empirically over other methods. Our examples illustrate that CE captures the topological structure, i.e., neighborhoods of the data, comparable to methods, but with lower cost and generally better prediction error. These experiments include comparisons to the unsupervised Laplacian eigenmaps, UMAP, pt-SNE, autoencoders; the supervised UMAP, SPCA, KSPCA as well as the MCML and NCA class of algorithms. The algorithms that have the most similar prediction errors when compared to CE require the computation of distances between all pairs of points. We demonstrated that the 2D embedding of centroid-encoder produces competitive, if not optimal, prediction errors. We also showed empirically that the model globally captures high statistical variance relative to optimal linear transformations, i.e., more than PCA.

In addition to capturing the global topological structure of the data in low-dimensions, CE exploits data labels to minimize the within-class variance. This improves the localization of the mapping such that points are mapped more faithfully to their Voronoi regions in low-dimensions. CE also provides a mapping model that can be applied to new data without any retraining being necessary. This is in contrast to the spectral methods described here that require the entire training and testing set for computing the embedding eigenvectors.

In the future, we plan to extend the model in unsupervised and semi-supervised learning.

## 9 Acknowledgement

The authors thank Shannon Stiverson and Eric Kehoe to review the article thoroughly and giving us their feedback to make the material better. We also thank Manuchehr Aminian to make sure that the code in GitHub is working correctly.

### Footnotes

- Manual for Supervised UMAP is located at https://readthedocs.org/projects/umap-learn/downloads/pdf/latest/
- The data set is available at http://yann.lecun.com/exdb/mnist/index.html.
- The data set is available at https://cs.nyu.edu/~roweis/data.html.
- The software is avilable at http://www.cis.hut.fi/research/software.
- This corresponds to the bottleneck layer for CE.
- Learning rate was selected from the following list of values: 0.1, 0.01, 0.001, 0.0001, 0.0002, 0.0004, 0.0008.
- Mini-batch size was selected from the following values: 16, 32, 50, 64, 128, 256, 512, 1024.
- Weight decay was chosen from the following values: 0.001, 0.0001, 0.00001, 0.00002, 0.00004, 0.00008.
- was picked from the following list of values: 5, 10, 20, 40, 80.
- was picked from the following list of values: 0.0125, 0.05, 0.2, 0.8.
- was picked from the following values: 0.001, 0.01, 0.025, 0.035, 0.05, 0.1, 1.0, 2.5, 3.0, 5.0, 7.5, 10.0.

### References

- (2006) Prediction by supervised principal components. Journal of the American Statistical Association 101 (473), pp. 119–137. External Links: Document, Link, https://doi.org/10.1198/016214505000000628 Cited by: §2.2.
- (1989-01) Neural networks and principal component analysis: learning from examples without local minima. Neural Netw. 2 (1), pp. 53–58. External Links: ISSN 0893-6080, Link, Document Cited by: §3.
- (2011-07) Supervised principal component analysis: visualization, classification and regression on subspaces and submanifolds. Pattern Recogn. 44 (7), pp. 1357–1371. External Links: ISSN 0031-3203, Link, Document Cited by: §2.2, §6.2, §6.
- (2003-06) Laplacian eigenmaps for dimensionality reduction and data representation. Neural Comput. 15 (6), pp. 1373–1396. External Links: ISSN 0899-7667, Link, Document Cited by: §2.1, §6.3.1.
- (2006) Greedy layer-wise training of deep networks. In Proceedings of the 19th International Conference on Neural Information Processing Systems, NIPS’06, Cambridge, MA, USA, pp. 153–160. External Links: Link Cited by: §3, §3, §5.1.
- (2007) Greedy layer-wise training of deep networks. In Advances in Neural Information Processing Systems 19, B. Schölkopf, J. C. Platt and T. Hoffman (Eds.), pp. 153–160. External Links: Link Cited by: §3, §5.1.
- (2000) A new approach for dimensionality reduction: theory and algorithms. SIAM J. of Applied Mathematics 60 (6), pp. 2114–2142. Cited by: §1, §3.
- (2001) The Whitney reduction network: a method for computing autoassociative graphs. Neural Computation 13, pp. 2595–2616. Cited by: §1, §3.
- (2012) Supervised isomap based on pairwise constraints. In Proceedings of the 19th International Conference on Neural Information Processing - Volume Part I, ICONIP’12, Berlin, Heidelberg, pp. 447–454. External Links: ISBN 978-3-642-34474-9, Link, Document Cited by: §2.2, §6.
- (1989-12-01) Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals and Systems 2 (4), pp. 303–314. External Links: ISSN 1435-568X, Document, Link Cited by: §3.
- (2017) DeepPainter: painter classification using deep convolutional autoencoders. CoRR abs/1711.08763. External Links: Link, 1711.08763 Cited by: §3.
- (2004) Sparse multidimensional scaling using landmark points. Technical report Technical report, Stanford University. Cited by: §2.1.
- (2017) UCI machine learning repository. University of California, Irvine, School of Information and Computer Sciences. External Links: Link Cited by: §6.1, §6.1, §6.1, §6.1.
- (1973) Pattern classification and scene analysis. John Willey & Sons, New York. Cited by: §2.2.
- (1936) The use of multiple measurements in taxonomic problems. Annals of Eugenics 7 (7), pp. 179–188. Cited by: §2.2.
- (2018) New tools for the visualization of biological pathways. Methods 132, pp. 26 – 33. Note: Comparison and Visualization Methods for High-Dimensional Biological Data External Links: ISSN 1046-2023, Document, Link Cited by: §2.2.
- (2006) Metric learning by collapsing classes. In Advances in neural information processing systems, pp. 451–458. Cited by: §2.2.
- (2004) Neighbourhood components analysis. In Proceedings of the 17th International Conference on Neural Information Processing Systems, NIPS’04, Cambridge, MA, USA, pp. 513–520. External Links: Link Cited by: §2.2, §6.2, §6.
- (2016) Deep learning. MIT Press. Note: \urlhttp://www.deeplearningbook.org Cited by: §3.
- (2017) Deep clustering with convolutional autoencoders. In Neural Information Processing, D. Liu, S. Xie, Y. Li, D. Zhao and E. M. El-Alfy (Eds.), Cham, pp. 373–382. External Links: ISBN 978-3-319-70096-0 Cited by: §3.
- (2003) Stochastic neighbor embedding. In Advances in Neural Information Processing Systems 15, S. Becker, S. Thrun and K. Obermayer (Eds.), pp. 857–864. External Links: Link Cited by: §2.1.
- (2006) Reducing the dimensionality of data with neural networks. science 313 (5786), pp. 504–507. Cited by: §1, §3.
- (2006-07) A fast learning algorithm for deep belief nets. Neural Comput. 18 (7), pp. 1527–1554. External Links: ISSN 0899-7667, Link, Document Cited by: §1, §3, §5.1.
- (1989-07) Multilayer feedforward networks are universal approximators. Neural Netw. 2 (5), pp. 359–366. External Links: ISSN 0893-6080, Link, Document Cited by: §3.
- (1933) Analysis of a complex of statistical variables into principal components. Journal of Educational Psychology September. Cited by: §1, §2.1.
- (1995) Spherical nodes in neural networks with applications. In Intelligent Engineering Through Artificial Neural Networks, S.H. Dagli, B.R. Fernandez, J. Ghosh and R.T. S. Kumara (Eds.), Vol. 5, New York, pp. 27–32. Cited by: §3.
- (2007-09) Parametric embedding for class visualization. Neural Comput. 19 (9), pp. 2536–2556. External Links: ISSN 0899-7667, Link, Document Cited by: §2.2, §6.
- (1986) Principal component analysis. Springer, New York. Cited by: §2.1.
- (2016) Principal component analysis: a review and recent developments. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 374 (2065), pp. 20150202. Cited by: §1.
- (2014) Adam: A method for stochastic optimization. CoRR abs/1412.6980. External Links: Link, 1412.6980 Cited by: §6.2.
- (1996) Circular nodes in neural networks. Neural Computation 8 (2), pp. 390–402. Cited by: §3.
- (1999) Empirical dynamical system reduction I: global nonlinear transformations. In Semi-analytic Methods for the Navier–Stokes Equations (Montreal, 1995), K. Coughlin (Ed.), CRM Proc. Lecture Notes, Vol. 20, Providence, RI, pp. 41–64. Cited by: §3.
- (2001) Geometric data analysis: an empirical approach to dimensionality reduction and the study of patterns. Wiley. Cited by: §1, §3, §3, §7.1.
- (1982) Self-organized formation of topologically correct feature maps. Biol. Cybern. 43, pp. 59. Cited by: §2.1.
- (1991) Nonlinear principal component analysis using autoassociative neural networks. AIChE Journal 37 (2), pp. 233–243. External Links: ISSN 1547-5905, Link, Document Cited by: §3.
- (1991) Nonlinear principal component analysis using autoassociative neural networks. AIChE J. 37 (2), pp. 233–243. Cited by: §1, §3.
- (1992) Autoassociative neural networks. Comput. Chem. Engng. 16 (4), pp. 313–328. Cited by: §1, §3.
- (2008) Sparse deep belief net model for visual area v2. In Advances in Neural Information Processing Systems 20, J. C. Platt, D. Koller, Y. Singer and S. T. Roweis (Eds.), pp. 873–880. External Links: Link Cited by: §3.
- (1980-01) An algorithm for vector quantization design. IEEE transactions on Communications 28 (1), pp. 84–95. Note: Cited by: §4.1.
- (2011) Stacked convolutional auto-encoders for hierarchical feature extraction. In Proceedings of the 21th International Conference on Artificial Neural Networks - Volume Part I, ICANN’11, Berlin, Heidelberg, pp. 52–59. External Links: ISBN 978-3-642-21734-0, Link Cited by: §3.
- (2018) Umap: uniform manifold approximation and projection for dimension reduction. arXiv preprint arXiv:1802.03426. Cited by: §2.1, §6.
- (2004) Multiple relational embedding. In Proceedings of the 17th International Conference on Neural Information Processing Systems, NIPS’04, Cambridge, MA, USA, pp. 913–920. External Links: Link Cited by: §6.
- (2010) Deep supervised t-distributed embedding. In Proceedings of the 27th International Conference on Machine Learning (ICML-10), pp. 791–798. Cited by: §2.2, §6.2, §6.2, §6.2, Table 3, §6.
- (2017) Exemplar-centered supervised shallow parametric data embedding. arXiv preprint arXiv:1702.06602. Cited by: §2.2, Table 4, §6.
- (1991) Data compression, feature extraction, and autoassociation in feedforward neural networks. In Artificial Neural Networks, T. Kohonen, K. Mäkisara., O. Simula and J. Kangas (Eds.), NY, pp. 737–745. Cited by: §1.
- (1901) On lines and planes of closest fit to systems of points in space. Phil. Mag. S. 2 (11), pp. 559–572. Cited by: §1, §2.1.
- (2011-11) Scikit-learn: machine learning in python. J. Mach. Learn. Res. 12, pp. 2825–2830. External Links: ISSN 1532-4435, Link Cited by: §2.2, §6.
- (2012-06) A supervised non-linear dimensionality reduction approach for manifold learning. Pattern Recogn. 45 (6), pp. 2432–2444. External Links: ISSN 0031-3203, Link, Document Cited by: §2.2.
- (2007) Sparse feature learning for deep belief networks. In Proceedings of the 20th International Conference on Neural Information Processing Systems, NIPS’07, USA, pp. 1185–1192. External Links: ISBN 978-1-60560-352-0, Link Cited by: §3.
- (2000) Nonlinear dimensionality reduction by locally linear embedding. SCIENCE 290, pp. 2323–2326. Cited by: §2.1.
- (1985) Learning internal representations by error propagation. Technical report DTIC Document. Cited by: §3.
- (2007) Learning a nonlinear embedding by preserving class neighbourhood structure. In Artificial Intelligence and Statistics, pp. 412–419. Cited by: §2.2, §6.
- (2007) Colored maximum variance unfolding. In NIPS, Cited by: §2.2, §6.
- (2012) Feature extraction with deep neural networks by a generalized discriminant analysis. IEEE transactions on neural networks and learning systems 23 (4), pp. 596–608. Cited by: §2.2, Table 3, §6.
- (2000) A global geometric framework for nonlinear dimensionality reduction. Science 290 (5500), pp. 2319–2323. External Links: Document, ISSN 0036-8075, Link, http://science.sciencemag.org/content/290/5500/2319.full.pdf Cited by: §2.1.
- (1952) Multidimensional scaling: i. theory and method. Psychometrika 17, pp. 401–419. Cited by: §2.1.
- (2008) Visualizing data using t-SNE. Journal of Machine Learning Research 9, pp. 2579–2605. External Links: Link Cited by: §2.1.
- (2009) Learning a parametric embedding by preserving local structure. In AISTATS, JMLR Proceedings, Vol. 5, pp. 384–391. Cited by: §6.2, Table 3, §6.
- (2010-03) Information retrieval perspective to nonlinear dimensionality reduction for data visualization. J. Mach. Learn. Res. 11, pp. 451–490. External Links: ISSN 1532-4435, Link Cited by: §2.2, §6.2, §6.2, Table 5, §6.
- (2010-12) Stacked denoising autoencoders: learning useful representations in a deep network with a local denoising criterion. J. Mach. Learn. Res. 11, pp. 3371–3408. External Links: ISSN 1532-4435, Link Cited by: §3.
- (1965) Karhunen–Loève expansion and factor analysis.. In Trans. 4th. Prague Conf. on Inf. Theory, Statist. Decision Functions, and Random Proc., Prague, pp. 635–660. Cited by: §2.1.
- (2006) An introduction to nonlinear dimensionality reduction by maximum variance unfolding. In Proceedings of the 21st National Conference on Artificial Intelligence - Volume 2, AAAI’06, pp. 1683–1686. External Links: ISBN 978-1-57735-281-5, Link Cited by: §2.1.
- (1974-08) Beyond regression: new tools for prediction and analysis in the behavioral sciences. PhD Dissertation, Harvard University. Cited by: §3.
- (2009-10) Enhanced supervised locally linear embedding. Pattern Recogn. Lett. 30 (13), pp. 1208–1218. External Links: ISSN 0167-8655, Link, Document Cited by: §2.2.