# Introduction

The paper <ref>Salakhutdinov, R., & Hinton, G. E. (2007). Learning a nonlinear embedding by preserving class neighbourhood structure. AI and Statistics.</ref> presented here describes a method to learn a nonlinear transformation from the input space to a low-dimensional feature space in which K-nearest neighbour classification performs well. As the performance of algorithms like K-nearest neighbours (KNN) that are based on computing distances, the main objective of the proposed algorithm is to learn a good similarity measure that can provide insight into how high-dimensional data is organized. The nonlinear transformation is learned by pre-training and fine-tuning a multilayer neural network. The authors also show how to enhance the performance of non-linear transformation further using unlabeled data. Experimental results on a widely used version of the MNIST handwritten digit recognition task show that proposed algorithm achieves a much lower error rate than SVM or standard backpropagation.

# Clustering

Clustering refers to partition a given dataset into clusters such that data points in the same cluster are similar and data points in different clusters are dissimilar. Similarity is usually measured over distance between data points.

Formally stated, given a set of data points $X=\{{{\mathbf x}}_1,{{\mathbf x}}_2,\dots ,{{\mathbf x}}_P\}$, we would like to find $K$ disjoint clusters ${C{\mathbf =}\{C_k\}}_{k\in \{1,\dots ,K\}}$ such that $\bigcup{C_k}=X$, that optimizes a certain objective function. The dimensionality of data points is $D$, and $X$ can be represented as a matrix ${{\mathbf X}}_{D\times P}$.The similarity matrix that measures the similarity between each pair of points is denoted by ${{\mathbf W}}_{P\times P}$. A classical similarity matrix for clustering is the diagonally-scaled Gaussian similarity, defined as
$\mathbf W(i,j)= \rm exp (-(\mathbf{x}_i-\mathbf{x}_j)^{\rm T}Diag(\boldsymbol{\alpha})(\mathbf{x}_i-\mathbf{x}_j) )$
where ${\mathbf \boldsymbol{\alpha} }\in {{\mathbb R}}^D$ is a vector of positive parameters, and $\rm Diag(\boldsymbol{\alpha} )$ denotes the $D\times D$ diagonal matrix with diagonal ${\boldsymbol{\alpha} }$.

# Objective functions

## Objective function for K-means clustering

Given the number of clusters $K$, it aims to minimize an objective function (sum of within-cluster distance) over all clustering scheme $C$.
$\mathop{\min_C} J=\sum^K_{k=1}\sum_{\mathbf x \in C_k}\|\mathbf x - \boldsymbol{\mu}_k\|^2$
${\boldsymbol{\mu}}_k{\mathbf =}\frac{{\mathbf 1}}{\left|C_k\right|}\sum_{{\mathbf x}\in C_k}{{\mathbf x}}$ is the mean of the cluster $C_k$

## Min cut

For two subsets of $A,B\subset X$, we define
$cut(A,B)=\sum_{{\mathbf x}_i \in A}\sum_{{\mathbf x}_j \in B}\mathbf W (i,j)$
Mincut is the sum of inter-cluster weights.
$Mincut(C)=\sum^K_{k=1} cut(C_k,X \backslash C_k)$

## Normalized cut

The normalized cut in the paper is defined as
$Ncut(C)=\sum^K_{k=1}\frac{cut(C_k,X\backslash C_k)}{cut(C_k,X)}=\sum^K_{k=1}\frac{cut(C_k,X)-cut(C_k,C_k)}{cut(C_k,X)}=K-\sum^K_{k=1}{\frac{cut(C_k,C_k)}{cut(C_k,X)}}$
Normalized cut takes a small value if the clusters $C_k$ are not too small <ref> Ulrike von Luxburg, A Tutorial on Spectral Clustering, Technical Report No. TR-149, Max Planck Institute for Biological Cybernetics.</ref> as measured by the intra-cluster weights. So it tries to achieve balanced clusters. There is unlikely that we will have clusters containing one data point.

## The matrix representation of Normalized cut

Let ${{\mathbf e}}_k\in {\{0,1\}}^P$ be the indicator vector for cluster $C_k$, where the non-zero elements indicate the data points in cluster $C_k$. Therefore, knowing ${\mathbf E}{\mathbf =}({{\mathbf e}}_1,\dots ,{{\mathbf e}}_K)$ is equivalent to know clustering scheme $C$. Further let ${\mathbf D}$ denotes the diagonal matrix whose $i$-th diagonal element is the sum of the elements in the $i$-th row of ${\mathbf W}$, that is, ${\mathbf D}{\mathbf =}{\rm Diag(}{\mathbf W}\cdot {\mathbf 1}{\rm )}$, where ${\mathbf 1}$ is defined as the vector in ${\{1\}}^P$.
So the normalized cut can be written as
$Ncut(C)=C(\mathbf{W,E})=\sum^K_{k=1}\frac{{\mathbf e}^{\rm T}_k (\mathbf{D-W}){\mathbf e}_k}{{\mathbf e}^{\rm T}_k (\mathbf{D}){\mathbf e}_k}=K-tr(\mathbf {E^{\rm T} W E}(\mathbf {E^{\rm T} D E})^{-1})$

# Spectral Clustering

Solving the problem of Normalized cut is NP-hard, so we turn to the relaxed version of it.

## Theorem 1

Minimizing normalized cut over all $C$ is equivalent to the following optimization problem (refer as original optimization problem).
$\mathop{\min_{\mathbf Y}}K-tr(\mathbf{Y^{\rm T}(D^{\rm{1/2}}WD^{\rm{1/2}})Y})$
subject to
${\mathbf Y}{\mathbf =}{{\mathbf D}}^{{{\rm 1}}/{{\rm 2}}}{\mathbf E}{\mathbf \Lambda }$ (1a)
and
${{\mathbf Y}}^{{\rm T}}{\mathbf Y}{\mathbf =}{\mathbf I}$ (1b)
Where ${\mathbf \Lambda }\in {{\mathbb R}}^{K\times K},{\mathbf Y}\in {{\mathbb R}}^{P\times K}$
In other words, given ${\mathbf E}$ and let$\mathbf{\Lambda =(E^{\rm T} D E)^{\rm{1/2}}}$, we can form a candidate solution ${\mathbf Y}{\mathbf =}{{\mathbf D}}^{{{\rm 1}}/{{\rm 2}}}{\mathbf E}{\left({{\mathbf E}}^{{\rm T\ }}{\mathbf {D E}}\right)}^{{\mathbf -}{{\rm 1}}/{{\rm 2}}}$ for the above optimization problem.

## Relaxed optimization problem

Since minimizing normalized cut is NP-hard problem, its equivalent optimization problem is NP-hard too. However, by removing the constraint (1a) in Theorem 1, a relaxed problem is obtained.

$\mathop{\min_{\mathbf Y}}K-tr(\mathbf{Y^{\rm T}(D^{\rm{1/2}}WD^{\rm{1/2}})Y})$
subject to
${{\mathbf Y}}^{{\rm T}}{\mathbf Y}{\mathbf =}{\mathbf I}$
Where ${\mathbf Y}\in {{\mathbb R}}^{P\times K}$