High Dimension Data Analysis - A tutorial and review for Dimensionality Reduction Techniques

In the current day and age, high dimensional datasets are a common occurrence in most areas of study, with the high volume and variety of data that streams in. Research in the field of deep learning and machine learning have led to development of high efficiency models and algorithms that can deal with high volume of high dimensional datasets. However, there are techniques to engineer some significant variables and reduce the dimensionality by either eliminating other redundant variables or by creating new variables by combining a few existing ones. High dimensionality poses a few problems and hence need to be dealt with. Some of these issues are:
  • High number of variables lead to higher computational and time complexity of machine learning models. Reducing the dimensionality can improve the efficiency of these models.
  • High number of variables in a dataset, when fed to a machine learning model can lead to overfitting, thus reducing the generalizability of the machine learning models
  • High number of variables in a dataset may make it noisy and increases ambiguity. By reducing the dimensionality and selecting features, we can improve the information content of the dataset.
  • Lower dimensionality of a dataset helps in visualizing it better.
  • For certain models like regression models, high number of variables may include some variables which have a high correlation with the target variable. This poses the problem of multicollinearity.
  • In this article, we investigate and study a few methods for selecting features from a high dimensional dataset, and thus reduce the dimensionality of the datasets.

    1. Feature Selection from base features

    Some techniques as described below are used to select features from the available base features in the dataset. These techniques do not alter the structure or definition of these variables, but simply select a subset of them.

    1.1. Low Variance and High Correlation Filters

    Statistically, variance is the measure of spread for a distribution of a random variable that determines the degree to which the values of a random variable differ from the expected value. In other words, it tells us how far the points are from the mean. The formula to variance is given by:
    σ 2 = Σ ( x x ¯ ) 2 n σ 2 = Σ ( x x ¯ ) 2 n sigma^(2)=(Sigma(x-( bar(x)))^(2))/(n)\sigma^{2}=\frac{\Sigma(x-\bar{x})^{2}}{n}
    If the variance is closer to zero, that means the variable is fairly constant and does not spread too far away from the mean. A variable with variance 0 means all the values of the variable are constant i.e. all values are the same.
    For a variable in the context of a dataset being prepared for machine learning, a variable with variance close to zero contains little to no information about the traget variable. This means it contains little impact on the target variable, and thus very little impact on the model's predictive ability.
    Since variance is dependent on the range of the variable, it is important to scale the variables, especially numerical variables before computing the variance. After the variances have been computed for all the scaled variables, you can choose a threshold for the variance. All variables with variance below the theshold can be dropped.
    For categorical variables, variables with few unique values but with more than 95% of the values belonging to a specific category can be dropped. For instance, if 95% of the records in a dataset belong to one particular country, say US, it is best to drop this variable as the information of the country would not improve or affect the performance of the model trained on this dataset.
    Boolean features are Bernoulli random variables, and the variance of such variables is given by:
    Var [ X ] = p ( 1 p ) Var [ X ] = p ( 1 p ) Var[X]=p(1-p)\operatorname{Var}[X]=p(1-p) For Boolean variables, we would want to remove all features that are either one or zero (true or false) in more than a certain threshold. For instance, if a variable has the value 'True' for 80% of the samples or more, we drop this variable. This threshold would be achieves using the above formula ( 0.8 ( 1 0.8 ) ) ( 0.8 ( 1 0.8 ) ) (0.8**(1-0.8))(0.8*(1-0.8)).
    A similar feature-selection criteria can be made on the basis of the correlation of the existing features. Multiple features which are highly correlated among themeselves can lead to multicollinearity in a model. In models, especially regression models, if a feature is a linear function of 1 or more features in the dataset, it makes it difficult to estimate the relationship between each independent variable and the dependent variable independently. Thus, it is important to eliminate multicollinearity by retaining only one of the highly correlated features.
    We use Pearson's correlation to find the correlation between numerical variables. To find correlations between categorical features, we can use the chi-squared test. The chi-squared statistical test considers 2 hypotheses:
  • H0 (Null Hypothesis) = The 2 variables to be compared are independent.
  • H1 (Alternate Hypothesis) = The 2 variables are dependent. Now, if the p-value obtained after conducting the test is less than 0.05, we reject the Null hypothesis and accept the Alternate hypothesis. If the p-value is greater that 0.05 we accept the Null hypothesis and reject the Alternate hypothesis i.e. it implies that the 2 variables are independent. A p-value of 0 would indicate that we can accept the alternate hypothesis with high confidence and that the two variables are highly correlated.
  • For determining the correlation between a categorical and a numerical variable, we can use correlation ratio ( η η eta\eta) which is defined as the weighted variance of the mean of each category divided by the variance of all samples. It helps us answer a simple question: Given a continuous number, how well can you know to which category it belongs to? The score has a range of [ 0 , 1 ] [ 0 , 1 ] [0,1][0,1] where a higher score indicates higher correlation. Using these scores, we can eliminate either of the variables in a pair that is highly correlated. One way of selecting a feature to retain, is to check the correlation of these features with the target. To train a model with good predictive ability, one should select the feature with a higher correlation with the target variable.

    1.2. Recursive Feature Elimination (RFE)

    Algorithm 1: Recursive Feature Elimination
    1.1 1.1 1.1\mathrm{1.1} Tune/Train the model on the training set using predictors S i , i = 1 , . . , S S i , i = 1 , . . , S S_(i),i=1,..,S\mathrm{S_{i}}, i=1,..,S
    1.2 1.2 1.2\mathrm{1.2} Determine the appropriate number of features in the final model ( n ) ( n ) (n)(n) and the subset size (number of features to be removed in each step: t t tt)
    1.3 1.3 1.3\mathrm{1.3} While i > n i > n i > ni > n do:
    1.3 .1 1.3 .1 1.3.1\mathrm{1.3.1} Calculate the importance of the predictors
    1.3 .2 1.3 .2 1.3.2\mathrm{1.3.2} Drop lowest t t tt features on the basis of lowest importance score
    1.3 .3 1.3 .3 1.3.3\mathrm{1.3.3} Tune/Train the model on the training set using the S i t S i t S_(i-t)S_{i-t} predictors
    1.3 .4 1.3 .4 1.3.4\mathrm{1.3.4} [Optional] Calculate model performance
    1.4 1.4 1.4\mathrm{1.4} end
    1.8 1.8 1.8\mathrm{1.8} Train the model using the optimal S n S n S_(n)S_{n} features
    Recursive Feature Elimination is wrapper-type feature selection technique. This means that a different machine learning algorithm is given and used in the core of the method, wrapped by RFE to help select features. Unlike filter-based feature selection methods that score each feature and select those features with the largest (or smallest) score, this method stops when it reaches a stopping criterion.
    In RFE, we aim to select features by recursively considering smaller sets of features in each iteration. First, the estimator is trained on the initial set of features, often the entire set of predictors and the importance score of each feature is computed either through any specific attribute like feature importance, p-values, variable coefficients or a callable. Then, the least important features are pruned from current set of features, the model is re-built, and importance scores are computed again. That procedure is recursively repeated on the pruned set until the desired number of features to select is eventually reached.
    One can specify the number of predictor subsets to evaluate as well as each subset’s size. Therefore, the variable subset size is a tuning parameter for RFE. The subset size that optimizes the performance criteria is used to select the predictors based on the importance rankings. The optimal subset is then used to train the final model.
    One important thing to note, is that the RFE method cannot be used with all models. RFE requires that the initial model uses the full predictor set. Hence, RFE cannot be used with some models like multiple linear regression, logistic regression, and linear discriminant analysis, when the number of predictors exceeds the number of samples. To use RFE in these cases, the number of predictors must first be reduced.

    1.3. Sequential Feature Selection (SFS)

    Sequential Feature Selection or SFS is another wrapper-method for feature selection. SFS can be either forward or backward. You can specify the desired number of features. The feature selection algorithm removes or adds one feature at a time based on the model performance until a feature subset of the desired size k k kk is reached.
    Forward-SFS is a greedy algorithm that iteratively finds the best new feature to add to the set of selected features. We initially start with zero features and find the one feature that maximizes a cross-validated score when an estimator is trained on this single feature. Once that first feature is selected, we repeat the procedure by adding a new feature to the set of selected features. The procedure stops when the desired number of selected features ( k ) ( k ) (k)(k) is reached.
    Backward-SFS follows the same idea but works in the opposite direction: instead of starting with no feature and greedily adding features, we start with all the features and greedily remove features from the set. The direction parameter controls whether forward or backward SFS is used.
    Algorithm 2: Backward SFS
    1.1 1.1 1.1\mathrm{1.1} Define the desired number of features
    1.2 1.2 1.2\mathrm{1.2} Tune/Train the model on the training set using all predictors
    1.3 1.3 1.3\mathrm{1.3} Compute Model Performance
    1.4 1.4 1.4\mathrm{1.4} Calculate the importance of the predictors
    1.5 1.5 1.5\mathrm{1.5} For each each subset of variables S i , S i , S_(i),\mathrm{S_{i},} i = 1 , . . . , S i = 1 , . . . , S i=1,...,Si=1,...,S do:
    1.5 .1 1.5 .1 1.5.1\mathrm{1.5.1} Greedily drop the feature responsible for the worst model performance at the given point; retain S i S i S_(i)S_{i} predictors
    1.5 .2 1.5 .2 1.5.2\mathrm{1.5.2} Tune/Train the model on the training set using the remaining S i S i S_(i)S_{i} predictors
    1.5 .3 1.5 .3 1.5.3\mathrm{1.5.3} Calculate model performance
    1.6 1.6 1.6\mathrm{1.6} end
    1.7 1.7 1.7\mathrm{1.7} Calculate the performance profile over the final S i S i S_(i)S_{i} features
    1.8 1.8 1.8\mathrm{1.8} Train the model using the optimal S i S i S_(i)S_{i} features
    While the forward SFS algorithm is easier to understand, there are minor diferences between backward SFS and RFE. SFS does not require the underlying model to expose variable coefficients or importance scores. The iterative step makes a greedy decision on the basis of the model performance. This algorithm includes a model selection on the basis of various parameters like Adj RSquared, Mallow's Cp, BIC or AIC, Accuracy or even Root Mean Squared Error (RMSE), depending on the nature of the model.
    SFS may however be slower considering that more models need to be evaluated, compared to RFE. For example in backward selection, the iteration going from m m mm features to m 1 m 1 m-1m - 1 features using k-fold cross-validation requires fitting m k m k m**km * k models, while RFE would require only a single fit.

    1.3.1. Definitions of some model-selection parameters

    AIC: The Akaike information criterion (AIC) is an estimator of out-of-sample prediction error and thereby relative quality of statistical models for a given set of data. It can be defined as:
    A I C = 2 ln ( L ) + 2 k A I C = 2 ln ( L ) + 2 k AIC=-2ln(L)+2kA I C=-2 \ln (L)+2 k
    Here, k k kk is the number of predictors or independent features and L L LL is the maximum value of the likelihood function for the model (The higher the number, the better the fit). We aim to minimize AIC, so the model with a lower AIC is selected as the better one.
    BIC: Bayesian Information Criteria (BIC) is a model selection parameter defined from Bayesian probability and inference. It can be defined as:
    B I C = k ln ( n ) 2 ln ( L ^ ) B I C = k ln ( n ) 2 ln ( L ^ ) BIC=k ln(n)-2ln( widehat(L))\mathrm{BIC}=k \ln (n)-2 \ln (\widehat{L})
    Here, ( L ^ ) ( L ^ ) ( widehat(L))(\widehat{L}) is the log-likelihood of the model, n n nn is the number of examples in the training dataset, and k k kk is the number of parameters in the model. Like AIC, we aim to minimize the BIC too i.e. we select the model with the lowest BIC. However, unlike AIC, BIC offers a higher penalty for complex models using the sample size of the dataset. If a model is trained on a dataset with a large sample size with relatively lower number of features, the model has a lower BIC, thus making it better than a model with smaller sample size and more features.
    MDL: The Minimum Description Length, or MDL for short, is a method for scoring and selecting a model. It is an information theoretic measure of model selection. It represents the minimum number of bits, or the minimum of the sum of the number of bits required to represent the data and the model and is defined as:
    M D L = L ( h ) + L ( D | h ) M D L = L ( h ) + L ( D | h ) MDL=L(h)+L(D|h)MDL = L(h) + L(D | h)
    Here, h h hh is the model, D D DD is the predictions made by the model, L ( h ) L ( h ) L(h)L(h) is the number of bits required to represent the model, and L ( D | h ) L ( D | h ) L(D|h)L(D | h) is the number of bits required to represent the predictions from the model on the training dataset.
    We also aim to reduce MDL, and hence the model with the lowest MDL is selected.

    1.4. Embedded Methods: L1 regularization for Feature Selection

    Let us talk about the two most common regularization techniques: L 1 L 1 L1L1 and L 2 L 2 L2L2. These regularization terms add a penalty that can be defined as:
    L1 norm penalty: α i = 1 n | w i | α i = 1 n | w i | alphasum_(i=1)^(n)|w_(i)|\alpha \sum_{i=1}^{n}|w_{i}| L2 norm penalty: α i = 1 n w i 2 α i = 1 n w i 2 alphasum_(i=1)^(n)w_(i)^(2)\alpha \sum_{i=1}^{n} w_{i}^{2}
    Here, L 1 L 1 L1L1 regularization, uses a penalty term which encourages the sum of the absolute values of the parameters to be small. L 2 L 2 L2L2 regularization, on the other hand, encourages the sum of the squares of the parameters to be small. It has frequently been observed that L 1 L 1 L1L1 regularization in many models causes many parameters to equal zero, so that the parameter vector is sparse. This makes it a natural candidate in feature selection settings, where we believe that many features should be ignored.
    image Graphical representation of L2 (left) and L1 (right) regularization
    In the above images, we see that L 1 L 1 L1L1 tends to generate sparser solutions than a quadratic regularizer like L 2 L 2 L2L2. In the formula defined fo L1-norm penalty, if we increase α α alpha\alpha further, the solution would become sparser and sparser, i.e. more and more features would have 0 as coefficients. The orange square area in the graph above will shrink to a point corresponding to 0.
    Thus, including a regularization term like L1-regularization with a machine learning model like linear regression to perform an embedded feature selection. Lasso regression uses L1 regularization on top of linear regression. It is like linear regression, but it uses a technique "shrinkage" where the coefficients of determination are shrunk towards zero.

    1.5. Tree-based Feature Selection

    Tree-based models can be used to compute impurity-based feature importances, which in turn can be used to discard irrelevant features. Let us consider the Random Forest models which computes importance scores for each feature based on the ‘Gini’ criterion during the training process. The Gini index is defined as follows:
    Gini ( D ) = 1 i = 1 k p i 2 Gini ( D ) = 1 i = 1 k p i 2 Gini(D)=1-sum_(i=1)^(k)p_(i)^(2)\operatorname{Gini}(D)=1-\sum_{i=1}^{k} p_{i}^{2}
    Here, given a dataset D D DD that contains samples from k k kk classes, the probability of samples belonging to class i i ii at a given node can be denoted as p i p i p_(i)p_{i}. The measure above tells us the probability of misclassifying an observation. Lower the Gini impurity, the better is the split. At every split ofa node in tree-based models, an attribute with the smallest Gini Impurity is selected for splitting the node.
    In other words, a lower Gini impurity index leads to a lower likelihood of misclassification. We can use impurity-based feature importances to discard irrelevant features using a meta-transformer for selecting features based on importance weights.

    2. Feature Extraction using Transformation/ Combination of Features

    There are a few methods that transform existing variables in the base dataset and/or combine them with other features to reduce the dimensionality while retaining maximum information/variance in the dataset.
    These methods can be classifed as linear or non-linear methods. The linear methods involve linearly projecting the original data onto a low-dimensional space and extract the transformed features. Some of these methods involve Principal Component Analysis (PCA), Factor Analysis (FA), Linear Discriminant Analysis (LDA) and Truncated Singular Value Decomposition (Truncated SVD). We will also cover some non-linear methods which work better with non-linear data.Some of those methods are: Kernel PCA, t-distributed Stochastic Neighbor Embedding (t-SNE), Multidimensional Scaling (MDS), and Isometric mapping (Isomap)

    2.1. Principal Component Analysis (PCA)

    In a dataset with large number of variables, it can be difficult to study and interpret the relationships between these variables. There can be too many pairwise correlations between the variables to consider. Moreover, it is difficult to visualize these variables and relationships.
    To interpret the data in a more meaningful form, it is necessary to reduce the number of variables to a few, interpretable linear combinations of the data. Each linear combination will correspond to a principal component. This is the essence of PCA.
    Let us assume a random vector X X XX:
    X = ( X 1 X 2 X p ) X = X 1 X 2 X p "X"=([X_(1)],[X_(2)],[vdots],[X_(p)])\textbf{X} = \left(\begin{array}{c} X_1\\ X_2\\ \vdots \\X_p\end{array}\right)
    X X XX represents all the features, represented by each vector X 1 , X 2 , . . . , X p X 1 , X 2 , . . . , X p X_(1),X_(2),...,X_(p)X_1, X_2,...,X_p in a dataset. If we compute the variance-covariance matrix of the vectors, it looks like:
    var ( X ) = Σ = ( σ 1 2 σ 12 σ 1 p σ 21 σ 2 2 σ 2 p σ p 1 σ p 2 σ p 2 ) var ( X ) = Σ = σ 1 2 σ 12 σ 1 p σ 21 σ 2 2 σ 2 p σ p 1 σ p 2 σ p 2 "var"("X")=Sigma=([sigma_(1)^(2),sigma_(12),dots,sigma_(1p)],[sigma_(21),sigma_(2)^(2),dots,sigma_(2p)],[vdots,vdots,ddots,vdots],[sigma_(p1),sigma_(p2),dots,sigma_(p)^(2)])\text{var}(\textbf{X}) = \Sigma = \left(\begin{array}{cccc}\sigma^2_1 & \sigma_{12} & \dots &\sigma_{1p}\\ \sigma_{21} & \sigma^2_2 & \dots &\sigma_{2p}\\ \vdots & \vdots & \ddots & \vdots \\ \sigma_{p1} & \sigma_{p2} & \dots & \sigma^2_p\end{array}\right)
    If we consider the linear combinations as below:
    Y 1 = e 11 X 1 + e 12 X 2 + + e 1 p X p Y 2 = e 21 X 1 + e 22 X 2 + + e 2 p X p Y p = e p 1 X 1 + e p 2 X 2 + + e p p X p Y 1      =      e 11 X 1 + e 12 X 2 + + e 1 p X p Y 2      =      e 21 X 1 + e 22 X 2 + + e 2 p X p           Y p      =      e p 1 X 1 + e p 2 X 2 + + e p p X p {:[Y_(1),=,e_(11)X_(1)+e_(12)X_(2)+cdots+e_(1p)X_(p)],[Y_(2),=,e_(21)X_(1)+e_(22)X_(2)+cdots+e_(2p)X_(p)],[,,vdots],[Y_(p),=,e_(p1)X_(1)+e_(p2)X_(2)+cdots+e_(pp)X_(p)]:}\begin{array}{lll} Y_1 & = & e_{11}X_1 + e_{12}X_2 + \dots + e_{1p}X_p \\ Y_2 & = & e_{21}X_1 + e_{22}X_2 + \dots + e_{2p}X_p \\ & & \vdots \\ Y_p & = & e_{p1}X_1 + e_{p2}X_2 + \dots +e_{pp}X_p\end{array}
    Each of the above equations represent the Y i Y i Y_(i)Y_i variables as a function of the random data X X XX. Here each component Y i Y i Y_(i)Y_i represents a principal component, a combination of several features. The equations can be seen as linear regressions where you can predict Y i Y i Y_(i)Y_{i} from X 1 , X 2 , . . . . , X p X 1 , X 2 , . . . . , X p X_(1),X_(2),....,X_(p)X_1, X_2,....,X_p with coefficients e p 1 , e p 2 , . . . , e p p e p 1 , e p 2 , . . . , e p p e_(p1),e_(p2),...,e_(pp)e_{p1}, e_{p2},...,e_{pp}. Since Y i Y i Y_(i)Y_i is function of the random data X X XX, its variance can be represented as:
    var ( Y i ) = k = 1 p l = 1 p e i k e i l σ k l = e i Σ e i var ( Y i ) = k = 1 p l = 1 p e i k e i l σ k l = e i Σ e i "var"(Y_(i))=sum_(k=1)^(p)sum_(l=1)^(p)e_(ik)e_(il)sigma_(kl)=e_(i)^(')Sigmae_(i)\text{var}(Y_i) = \sum\limits_{k=1}^{p}\sum\limits_{l=1}^{p}e_{ik}e_{il}\sigma_{kl} = \mathbf{e}'_i\Sigma\mathbf{e}_i
    and the covariance between Y i Y i Y_(i)Y_i and Y j Y j Y_(j)Y_j can be defined as:
    cov ( Y i , Y j ) = k = 1 p l = 1 p e i k e j l σ k l = e i Σ e j cov ( Y i , Y j ) = k = 1 p l = 1 p e i k e j l σ k l = e i Σ e j "cov"(Y_(i),Y_(j))=sum_(k=1)^(p)sum_(l=1)^(p)e_(ik)e_(jl)sigma_(kl)=e_(i)^(')Sigmae_(j)\text{cov}(Y_i, Y_j) = \sum\limits_{k=1}^{p}\sum\limits_{l=1}^{p}e_{ik}e_{jl}\sigma_{kl} = \mathbf{e}'_i\Sigma\mathbf{e}_j
    Now, the coefficients can be represented as a vector:
    e i = ( e i 1 e i 2 e i p ) e i = e i 1 e i 2 e i p e_(i)=([e_(i1)],[e_(i2)],[vdots],[e_(ip)])\mathbf{e}_i = \left(\begin{array}{c} e_{i1}\\ e_{i2}\\ \vdots \\ e_{ip}\end{array}\right)
    Now, if we look at the first Principal Component: Y 1 Y 1 Y_(1)Y_1, it is the linear combination of the x-variables that has maximum variance (among all linear combinations). It accounts for as much variation in the data as possible. Hence the coefficients e 11 , e 12 , , e 1 p e 11 , e 12 , , e 1 p e_(11,)e_(12),dots,e_(1p)\boldsymbol { e } _ { 11 , } \boldsymbol { e } _ { 12 } , \ldots , \boldsymbol { e } _ { 1 p } are defined such that variance is maximized, given the constraint that the sum of the squared coefficients is equal to one. This constraint is required to obtain a unique answer. This means that the below variance is maximized:
    var ( Y 1 ) = k = 1 p l = 1 p e 1 k e 1 l σ k l = e 1 Σ e 1 var ( Y 1 ) = k = 1 p l = 1 p e 1 k e 1 l σ k l = e 1 Σ e 1 "var"(Y_(1))=sum_(k=1)^(p)sum_(l=1)^(p)e_(1k)e_(1l)sigma_(kl)=e_(1)^(')Sigmae_(1)\text{var}(Y_1) = \sum\limits_{k=1}^{p}\sum\limits_{l=1}^{p}e_{1k}e_{1l}\sigma_{kl} = \mathbf{e}'_1\Sigma\mathbf{e}_1
    subject to the constraint:
    e 1 e 1 = j = 1 p e 1 j 2 = 1 e 1 e 1 = j = 1 p e 1 j 2 = 1 e_(1)^(')e_(1)=sum_(j=1)^(p)e_(1j)^(2)=1\mathbf{e}'_1\mathbf{e}_1 = \sum\limits_{j=1}^{p}e^2_{1j} = 1
    Similarly, the second principal component is the linear combination of x-variables that explains the maximum proportion of the remaining variation, with the constraint that the sum of the squared coefficients is equal to one and the additional constraint that the correlation between the first and second component is 0. It implies that the below variance is maximized:
    var ( Y 2 ) = k = 1 p l = 1 p e 2 k e 2 l σ k l = e 2 Σ e 2 var ( Y 2 ) = k = 1 p l = 1 p e 2 k e 2 l σ k l = e 2 Σ e 2 "var"(Y_(2))=sum_(k=1)^(p)sum_(l=1)^(p)e_(2k)e_(2l)sigma_(kl)=e_(2)^(')Sigmae_(2)\text{var}(Y_2) = \sum\limits_{k=1}^{p}\sum\limits_{l=1}^{p}e_{2k}e_{2l}\sigma_{kl} = \mathbf{e}'_2\Sigma\mathbf{e}_2
    given the first and second principal components are uncorrelated:
    cov ( Y 1 , Y 2 ) = k = 1 p l = 1 p e 1 k e 2 l σ k l = e 1 Σ e 2 = 0 cov ( Y 1 , Y 2 ) = k = 1 p l = 1 p e 1 k e 2 l σ k l = e 1 Σ e 2 = 0 "cov"(Y_(1),Y_(2))=sum_(k=1)^(p)sum_(l=1)^(p)e_(1k)e_(2l)sigma_(kl)=e_(1)^(')Sigmae_(2)=0\text{cov}(Y_1, Y_2) = \sum\limits_{k=1}^{p}\sum\limits_{l=1}^{p}e_{1k}e_{2l}\sigma_{kl} = \mathbf{e}'_1\Sigma\mathbf{e}_2 = 0
    All subsequent principal components have this same property – they are linear combinations that account for as much of the remaining variation as possible and they are not correlated with the other principal components. Moreover, all principal components are uncorrelated with one another.
    To find coefficients e i j e i j e_(ij)e_{ij} for a Principal Component, we need to calculate the eigenvalues and eigenvectors of the variance-covariance matrix Σ Σ Sigma\Sigma. If the eigenvalues of the variance-covariance matrix are repesented by λ 1 , λ 2 , . . . , λ p λ 1 , λ 2 , . . . , λ p lambda_(1),lambda_(2),...,lambda _(p)\lambda_1, \lambda_2, ... , \lambda_p such that:
    λ 1 λ 2 λ p λ 1 λ 2 λ p lambda_(1) >= lambda_(2) >= cdots >= lambda _(p)\lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_p
    The corresponding eigenvectors can be represented as e 1 , e 2 , , e p e 1 , e 2 , , e p e_(1),e_(2),dots,e_(p)\boldsymbol{e}_1 , \boldsymbol{e}_2 , \dots , \boldsymbol{e}_p. It can be proved that the elements for these eigenvectors are the coefficients of our principal components.
    Since principal components are a combination of multiple variables, interpreting it can be tough. To do so, we can look at the correlation between the principal components and the individual variables. The direction and the magnitude of the correlation score with each of the variables tells us how each principal component can be interpreted. Say a particular principal component has a strong correlation of 0.95 with a variable X 1 X 1 X_(1)X_1, followed by strong correlation with 2 other variables [ X m , X n ] [ X m , X n ] [X_(m),X_(n)][X_m, X_n], we can say that this PC is predominantly a measure and a function of X 1 X 1 X_(1)X_1. If a PC has a strong negative correlation with a variable X k X k X_(k)X_k, it means the PC increases with a decreasing X k X k X_(k)X_k. Thus, it is a negative function of that variable.
    It is important to note that one should perform feature scaling before running PCA especially, if there is a significant difference in the scale between the features of the dataset. One can define the number of principal components to be extracted from a dataset. This could be defined using the proportion of the explained variance by each of these principal components.

    2.2. Factor Analysis (FA)

    Factor Analysis (FA) is a dimensionality reduction technique that also helps extract latent variables which are not directly measured in a single variable but rather inferred from other variables in the dataset. These latent variables are called factors. It models observed variables, and their covariance structure, in terms of a smaller number of these latent unobserved factors.
    To understand the algorithm, let us start with a vector X X XX containing all variables for all samples:
    X = ( X 1 X 2 X p ) X = X 1 X 2 X p "X"=([X_(1)],[X_(2)],[vdots],[X_(p)])\textbf{X} = \left(\begin{array}{c} X_1\\ X_2\\ \vdots \\X_p\end{array}\right)
    This is a random vector, with a population mean. Assume that vector of traits X X XX is sampled from a population with population mean vector:
    μ = ( μ 1 μ 2 μ p ) = population mean vector μ = μ 1 μ 2 μ p = population mean vector mu=([mu_(1)],[mu_(2)],[vdots],[mu _(p)])="population mean vector"\boldsymbol{\mu} = \left(\begin{array}{c}\mu_1\\\mu_2\\\vdots\\\mu_p\end{array}\right) = \text{population mean vector}
    Here, E ( X i ) = μ i E X i = μ i E(X_(i))=mu_(i)\mathrm { E } \left( X _ { i } \right) = \mu _ { i } denotes the population mean of variable i i ii. If we consider m m mm latent common factors f 1 , f 2 , , f m f 1 , f 2 , , f m f_(1),f_(2),dots,f_(m)f _ { 1 } , f _ { 2 } , \dots , f _ { m }, such that m << p m << p m<<pm << p, then the common factors can be represented as :
    f = ( f 1 f 2 f m ) = vector of common factors f = f 1 f 2 f m = vector of common factors f=([f_(1)],[f_(2)],[vdots],[f_(m)])="vector of common factors"\mathbf{f} = \left(\begin{array}{c}f_1\\f_2\\\vdots\\f_m\end{array}\right) = \text{vector of common factors}
    Now, we represent each variable as a regression function of these factors as follows:
    (1) X 1 = μ 1 + l 11 f 1 + l 12 f 2 + + l 1 m f m + ϵ 1 (2) X 2 = μ 2 + l 21 f 1 + l 22 f 2 + + l 2 m f m + ϵ 2 (3) (4) X p = μ p + l p 1 f 1 + l p 2 f 2 + + l p m f m + ϵ p (1) X 1 = μ 1 + l 11 f 1 + l 12 f 2 + + l 1 m f m + ϵ 1 (2) X 2 = μ 2 + l 21 f 1 + l 22 f 2 + + l 2 m f m + ϵ 2 (3) (4) X p = μ p + l p 1 f 1 + l p 2 f 2 + + l p m f m + ϵ p {:(1)X_(1)=mu_(1)+l_(11)f_(1)+l_(12)f_(2)+cdots+l_(1m)f_(m)+epsilon_(1),(2)X_(2)=mu_(2)+l_(21)f_(1)+l_(22)f_(2)+cdots+l_(2m)f_(m)+epsilon_(2),(3)vdots,(4)X_(p)=mu _(p)+l_(p1)f_(1)+l_(p2)f_(2)+cdots+l_(pm)f_(m)+epsilon _(p):}\begin{align} X_1 & = \mu_1 + l_{11}f_1 + l_{12}f_2 + \dots + l_{1m}f_m + \epsilon_1\\ X_2 & = \mu_2 + l_{21}f_1 + l_{22}f_2 + \dots + l_{2m}f_m + \epsilon_2 \\ & \vdots \\ X_p & = \mu_p + l_{p1}f_1 + l_{p2}f_2 + \dots + l_{pm}f_m + \epsilon_p \end{align}
    Here, the variable means μ 1 , . . . , μ p μ 1 , . . . , μ p mu_(1),...,mu_(p)\mu_{1}, ... , \mu_{p} can be regarded as the intercepts for the multiple regression models defined above. The regression coefficients l i j l i j l_(ij)l_{ij} are called factor loadings and can be collected into a matrix like:
    L = ( l 11 l 12 l 1 m l 21 l 22 l 2 m l p 1 l p 2 l p m ) = matrix of factor loadings L = l 11 l 12 l 1 m l 21 l 22 l 2 m l p 1 l p 2 l p m = matrix of factor loadings L=([l_(11),l_(12),dots,l_(1m)],[l_(21),l_(22),dots,l_(2m)],[vdots,vdots,,vdots],[l_(p1),l_(p2),dots,l_(pm)])="matrix of factor loadings"\mathbf{L} = \left(\begin{array}{cccc}l_{11}& l_{12}& \dots & l_{1m}\\l_{21} & l_{22} & \dots & l_{2m}\\ \vdots & \vdots & & \vdots \\l_{p1} & l_{p2} & \dots & l_{pm}\end{array}\right) = \text{matrix of factor loadings}
    Moreover, the error terms ( ϵ i ) ( ϵ i ) (epsilon _(i))(\epsilon_i) called the specific factors. The vector for the same can be represented as:
    ϵ = ( ϵ 1 ϵ 2 ϵ p ) = vector of specific factors ϵ = ϵ 1 ϵ 2 ϵ p = vector of specific factors epsilon=([epsilon_(1)],[epsilon_(2)],[vdots],[epsilon _(p)])="vector of specific factors"\boldsymbol{\epsilon} = \left(\begin{array}{c}\epsilon_1\\\epsilon_2\\\vdots\\\epsilon_p\end{array}\right) = \text{vector of specific factors}
    Each of our response variables X X XX is predicted as a linear function of the unobserved common factors $f_1,f_2,...,f_m $. We have m m mm unobserved factors that control the variation among our data.
    The factor model has a few assumptions though:
    1. The specific factors or random errors all have mean zero.
    2. The common factors have variance one.
    3. The common factors are uncorrelated with each other.
    4. The specific factors are uncorrelated with each other.
    5. The specific factors are uncorrelated with the common factors.
    We can interpret factor analysis as an inversion of principal components analysis. While PCA represents new components as a function of combination of observed variables, FA models the observed variables as linear functions of the new unobserved variables called factors. However, both PCA and FA reduce the dimension of the dataset.

    2.3. Linear Discriminant Analysis

    Linear Discriminant Analysis, or LDA, is a linear machine learning algorithm used for multi-class classification. It can also be used for dimensionality reduction.
    Let us assume a dataset with K K KK classes (for the target variable). LDA helps us reduce the number of features to K 1 K 1 K-1K-1 classes.
    The aim of LDA is to:
  • Minimize the Inter-Class Variability: This can be done by including as many similar points within a particular class. This will ensure less number of misclassifications.
  • Maximize the Distance Between the Mean of Classes: It tries to keep the class means apart from each other and as far as possible. This increases the confidence during prediction.
  • Thus, LDA tries to separate (or discriminate) the samples in the training dataset by their class value. In this pursuit of dimensionality reduction, the model tries to find a linear combination of input variables that achieves the maximum separation for samples between classes (class centroids or means) and the minimum separation of samples within each class.
    To explain this better, let us compare LDA to PCA. PCA is an unsupervised machine learning method, that is it takes into account only the spectral data and its variance to reduce the number of features. It does not require the labels of the data samples.
    However, LDA makes use of the class labels to produce a dimensionality reduction that maximizes the distance between the classes. In other words, while PCA will find the projections that maximise the variance of the data irrespective of their classes, LDA will seek to maximise the distance between those classes while reducing the number of features.
    image
    In the above image, we see how LDA projects the existing features onto an exis such that it separates the two classes in the projected space. The general overview of this algorithm looks like the following:
    Algorithm 3: Linear Discriminant Analysis
    1.1 1.1 1.1\mathrm{1.1} Compute the d-dimensional mean vector for the different classes from the dataset.
    1.2 1.2 1.2\mathrm{1.2} Compute the Scatter matrix (in between class and within the class scatter matrix)
    1.3 1.3 1.3\mathrm{1.3} Sort the Eigen Vector by decreasing Eigen Value and choosing k k kk eigenvector with the largest eigenvalue to from a d × k d × k d xx kd \times k dimensional matrix w w ww (where every column represent an eigenvector)
    1.4 1.4 1.4\mathrm{1.4} Used d × k d × k d xx kd \times k eigenvector matrix to transform the sample onto the new subspace.
    Although it looks like LDA can perform better than PCA in multi-class classification models, it is not always the case. The choice depends on the performance of the model built on the transformed dataset. One can also combine LDA and PCA as an ensemble to obtain transformed features.

    2.4. Truncated Singular Value Decomposition (SVD)

    The Singular-Value Decomposition, or SVD, is a matrix decomposition method for reducing a matrix to its constituent parts in order to make certain subsequent matrix calculations simpler. To understand Truncated SVD, let us briefly explain SVD.
    SVD is a method for low-dimensional representation of a high-dimensional matrix. In this process, it also makes it easy to eliminate the less important parts of that representation to produce an approximate representation with any desired number of dimensions. Thus, it is a dimensionality reduction technique.
    Let M M MM be an m × n m × n m xx nm × n matrix and rank r r rr. Now, we find matrices U U UU, Σ Σ SigmaΣ, and V V VV as shown in the image below:
    image Form of a singular-value decomposition
    It can be mathematically represented as:
    A m × n = U m × m . Σ m × n . V n × n T A m × n = U m × m . Σ m × n . V n × n T A_(m xx n)=U_(m xx m).Sigma_(m xx n).V_(n xx n)^(T)A_{m×n} = U_{m×m} . \Sigma_{m×n} . V^T_{n×n}
    Let us define the above matrices:
    1. U U UU is an m × r m × r m xx rm × r column-orthonormal matrix ; i.e., each of its columns is a unit vector and the dot product of any two columns is 0.
    2. V V VV is an n × r n × r n xx rn × r column-orthonormal matrix. Note that we always use V in its transposed form, so it is the rows of V T V T V^(T)V^T that are orthonormal.
    3. Σ Σ SigmaΣ is a diagonal matrix; that is, all elements not on the main diagonal are 0. The elements of Σ Σ SigmaΣ are called the singular values of M M MM.
    The key to understanding what SVD offers is in viewing the r r rr columns of U U UU, Σ Σ SigmaΣ, and V V VV as representing concepts that are hidden in the original matrix M M MM. To understand how it helps in dimensionality reduction, let us suppose we want to represent a very large matrix M M MM by its SVD components U U UU, Σ Σ SigmaΣ, and V V VV. However, these matrices are also too large to store conveniently. We can reduce the dimensionality of the three matrices by setting the smallest of the singular values to zero. If we set the s s ss smallest singular values to 0, then we can also eliminate the corresponding s s ss columns of U U UU and V V VV. We make the choice of setting the lowest singular values to zero when we reduce the number of dimensions minimizes the root-mean-square error (RMSE) between the original matrix M M MM and its approximation.
    In order to determine how many singular values need to be retained, it is a thumb-rule to retain enough singular values to make up 90% of the energy in Σ Σ SigmaΣ. This means, the sum of the squares of the retained singular values should be at least 90% of the sum of the squares of all the singular values.
    In truncated SVD, we take the k k kk largest singular values (such that 0 < k < r 0 < k < r 0 < k < r0<k<r) and their corresponding left and right singular vectors
    A m × n U t ( m × k ) , Σ t ( k × k ) , V t ( k × n ) T A m × n U t ( m × k ) , Σ t ( k × k ) , V t ( k × n ) T A_(m xx n)~~U_(t(m xx k)),Sigma_(t(k xx k)),V_(t(k xx n))^(T)A_{m×n}≈U_{t(m×k)},Σ_{t(k×k)},V^T_{t(k×n)}
    Contrary to PCA, this estimator does not center the data before computing the singular value decomposition. This means it can work with sparse matrices efficiently. Thus, we can used Truncated SVD as a dimensionality reduction technique for sparse datasets.

    2.5. Kernel PCA

    All the above methods are linear methods of dimensionality reduction. They work best for linear data. To be able to reduce the dimensions of non-linear data, we need non-linear methods. The first one discussed here is Kernel PCA. It is a non-linear version of PCA that uses kernels.
    image Linear and Non-linear dataset
    In the above figure, the data on the left is linearly separable. The one on the right is non-linear and needs a higher order polynomial to divide the complex boundary.
    In the conventional PCA algorithm, the process of matrix decomposition into eigenvectors is a linear transformation. Kernel PCA can be used to reduce the dimensions of data during classification of data whose decision boundaries are described by non-linear function. The idea is to go to a higher dimension space in which the decision boundary becomes linear. Let's say the decision boundary of the above data distribution is defined by a third order polynomial y = a + b x + c x 2 + d x 3 y = a + b x + c x 2 + d x 3 y=a+bx+cx^(2)+dx^(3)y = a + bx + cx^{2} + dx^{3}. If we plot this function on an x y x y x-yx-y plane, it will produce a wavy line, which could act as the decision boundary in the image above. Now if we project this to a higher-dimension space with axes x , x 2 , x 3 x , x 2 , x 3 x,x^(2),x^(3)x,x^{2}, x^{3} and y y yy. In this 4D space, the third order polynomial becomes a linear function and the decision boundary converts into a hyperplane. So, if we find a suitable transformation to convert our data into linear data, we can proceed to the usual PCA decomposition on the transformed data.
    Thus the algorithm can be simplified as below:
    Algorithm 4: Kernel PCA
    1.1 1.1 1.1\mathrm{1.1} Define the original set of n n nn features as x x x\mathrm{x}
    1.2 1.2 1.2\mathrm{1.2} Define ϕ ( x ) ϕ ( x ) phi(x)\phi(\mathbf{x}) as the non-linear combination (mapping) of these variables into a m > n m > n m > nm>n dataset
    1.3 1.3 1.3\mathrm{1.3} Define the kernel function: compute the kernel function κ ( x ) = ϕ ( x ) ϕ T ( x ) κ ( x ) = ϕ ( x ) ϕ T ( x ) kappa(x)=phi(x)phi^(T)(x)\kappa(\mathbf{x}) = \phi(\mathbf{x})\phi^{T}(\mathbf{x})
    1.4 1.4 1.4\mathrm{1.4} Calculate the squared Euclidean distance between each pair of points in the dataset.
    1.5 1.5 1.5\mathrm{1.5} Pass the distance matrix through the defined kernel to compute the kernel matrix for the given dataset.
    1.6 1.6 1.6\mathrm{1.6} Calculate the eigenvalues and eigenvectors of the kernel matrix
    1.7 1.7 1.7\mathrm{1.7} Flip eigenvectors' sign to enforce deterministic output
    1.8 1.8 1.8\mathrm{1.8} Concatenate the eigenvectors corresponding to the highest n n nn (where n n nn is the number of desired components) eigenvalues.
    One caveat in using Kernel PCA is that one has to define a value for the ( g a m m a ) ( g a m m a ) (gamma)\textbf(gamma) hyperparameter, which is the kernel coefficient, before running the algorithm. One thus needs to run a hyperparameter tuning technique like Grid Search to determine an optimal value for this parameter.

    2.6. t-distributed Stochastic Neighbor Embedding (t-SNE)

    This is a widely used dimensionality reduction technique for data visualization, image processing and NLP. The algorithm can be described using these broad steps:
    Algorithm 5: t-SNE
    1.1 1.1 1.1\mathrm{1.1} Compute the Euclidean distance matrix for all points from each other
    1.2 1.2 1.2\mathrm{1.2} Transform the distances into conditional probabilities that represent the similarity between every two points
    1.3 1.3 1.3\mathrm{1.3} Using the conditional probabilities, compute joint probability function: p i j = ( p j | i + p i | j ) / 2 n p i j = ( p j | i + p i | j ) / 2 n p_(ij)=(p_(j|i)+p_(i|j))//2np_{ij} = (p_{j|i}+p_{i|j})/2n using a Gaussian function
    1.4 1.4 1.4\mathrm{1.4} Build a random dataset of points with the same number of points as in the original dataset, and K K KK features, where K K KK is the desired number of features.
    1.5 1.5 1.5\mathrm{1.5} For this new dataset, create their joint probability distribution using the t-distribution (instead of Gaussian distribution)
    1.4 1.4 1.4\mathrm{1.4} Ese the Kullback-Leiber (KL) divergence to make the joint probability distribution of the data points in the low dimension (new random dataset) as similar as possible to the one from the original dataset.
    1.5 1.5 1.5\mathrm{1.5} The new transformation gives us a new dataset with reduced dimensions
    We choose t-distribution instead of the Gaussian distribution because of the heavy tails property of the t-distribution. This leads to moderate distances between points in the high-dimensional space to become extreme in the low-dimensional space, and that helps prevent “crowding” of the points in the lower dimension.
    We use KL-divergence as a measure of how much two distributions are different from one another. Lower the value of KL-divergence, more similar are the distributions. To find the new dataset with the reduced dimensions, we use the gradient descent optimization. The cost function that the gradient descent tries to minimize is the KL divergence of the joint probability distribution from the high-dimensional space and the low-dimensional space.
    Another advantage of using t-distribution is that it helps improve the efficiency of the gradient-descent optimization process.

    2.7. Multidimensional Scaling (MDS)

    MDS is a non-linear dimensionality reduction technique that tries to preserve the distances between samples while reducing the dimensionality of non-linear data. It is also known as Principal Coordinates Analysis (PCoA), Torgerson Scaling or Torgerson–Gower scaling.
    The main objective of MDS is to represent dissimilarities between data points as distances between points in a low dimensional space such that the distances correspond as closely as possible to the dissimilarities. The classical MDS algorithm, also called metric scaling can be described as below:
    Algorithm 6: Classical MDS
    1.1 1.1 1.1\mathrm{1.1} Given a matrix D D DD with dimesnionality m m mm, find matrix X X XX with the reduced dimension p p pp
    1.2 1.2 1.2\mathrm{1.2} From matrix D D DD, compute a matrix B B BB, by applying a centering matrix to D D DD
    1.3 1.3 1.3\mathrm{1.3} Determine the largest eigenvalues ( λ 1 , λ 2 , . . . , λ n 1 ) ( λ 1 , λ 2 , . . . , λ n 1 ) (lambda_(1),lambda_(2),...,lambda_(n-1))(\lambda_1, \lambda_2,...,\lambda_{n-1}) and corresponding eigenvectors ( v 1 , v 2 , . . , v n 1 ) ( v 1 , v 2 , . . , v n 1 ) (v_(1),v_(2),..,v_(n-1))(v_1,v_2,..,v_{n-1}) of matrix B B BB w.r.t p p pp
    1.4 1.4 1.4\mathrm{1.4} Get the square root of the dot product of the matrix of eigenvectors and the diagonal matrix of eigenvalues of B B BB
    This algorithm is now synonymous with Principal Coordinates Analysis. This is the metric MDS that deals with numerical distances, in which there is no measurement error (you have exactly one distance measure for each pair of items).
    Non-metric MDS deals with non-numerical distances between items, in which there is no measurement error (you have exactly one distance measure for each pair of items). Thus, in non-metric Multidimensional Scaling, we compute a dissimilarity matrix instead of a distance matrix.

    2.8. Isometric mapping (Isomap)

    This non-linear technique of dimensionality reduction is an extension of MDS or Kernel PCA. This algorithms uses curved or geodesic distance to connect eah instance to its nearest neighbors and reduces dimensionality.
    The broad steps of this algorithm can be described as below:
    Algorithm 7: Isomap
    1.1 1.1 1.1\mathrm{1.1} Define k k kk as the arbitrary number of neighbors to be discovered for each data point
    1.2 1.2 1.2\mathrm{1.2} Use KNN-approach to find the k k kk nearest neighbors of every data point
    1.3 1.3 1.3\mathrm{1.3} Construct the neighborhood graph where points are connected to each other if they are each other’s neighbors
    1.4 1.4 1.4\mathrm{1.4} Compute the shortest path or the geodesic distance between each pair of data points using either Floyd-Warshall or Dijkstra’s algorithm
    1.5 1.5 1.5\mathrm{1.5} Use MDS to compute lower-dimensional embedding
    Use of MDS ensures that each object into the N-dimensional space (where N N NN is a user-defined hyperparameter) such that the between-point distances are preserved as well as possible.
    image Comparison of linear Euclidean distance and Geodesic distance between two points on a non-linear data representation
    The use of the geodesic distance ensures that we do not misrepresent the distance between two points in a non-linear data distribution. IN the above image, if we look at points A and B, they appear to be much closer to each other if Euclidean distance is used to compute the distance between the two points. However, geodesic distances traces the path between the 2 points on the basis of the data distribution and is hence a more accurate representation of the distance between them. Use of a linear dimensionality reduction technique would hence, not be accurate.

    3. AutoEncoder for Dimensionality Reduction

    Autoencoders are artificial neural networks used for unsupervised learning. They are responsible for efficient coding or representation of data.
    image Architecture of a simple autoencoder
    The above image shows the architecture of a simple autoencoder. It consists of an encoder-decoder network. Here, the encoder takes the input and transforms it into a compressed representation i.e. encoding, and then passes it to the decoder. The decoder, as the name suggests, seeks to reconstruct the original representation from the encoded data, as accurately as possible. The goal is to learn an encoded representation for a dataset. Looking at the image above, it follows a bottle-neck architecture, which indicates that the dimensions of the encoded output from the encoder i smaller than the original input.
    This architecture forces the autoencoder to compress the training data’s informational content, and embed it into a low-dimensional space.
    Like any other neural network, there is a lot of flexibility in how autoencoders can be constructed such as the number of hidden layers and the number of nodes in each, along with the activation function of eavh layer. With each hidden layer the network will attempt to find new structures in the data.
    Comparison of PCA and Autoencoder for dimensionality reduction
    Parameter PCA Autoencoders (AE)
    Data transformation PCA follows linear transformation of data Autoencoders can be either linear or non-linear on the basis of the activation function
    Computational Efficiency PCA is relatively faster Autoencoders use Gradient descent optimization and is slower
    Data Sample Size PCA works best with smaller datasets Autoencoders can be used for large datasets
    Hyperparameter Tuning/ Input parameters PCA need a hyperparameter k k kk to define number of desired features Autoencoders have a complex architecture that needs to defined. This needs an activation function, number of dimensions in the encoding, number of nodes in each layer and number of layers in the network etc.
    Let us try to construct a simple Autoencoder for dimensionality reduction:
    image Simple autoencoder for dimensionality reduction from 30 inout features to 10 features
    The above autoencoder (built using Keras in Python) seeks to represent an input dataset with 30 features as an encoded space with 10 features. The encoder and decoder and constructed separately (in most cases, the AE is symmetrical i.e. the encoder and decoder are complementary to each other). At the end, they are stitched together to create the AE. We then need to train the autoencoder i.e. fit it on our dataset. We can then extract the encoded space from the encoder step of the AE.

    4. Additional Algorithms for Dimensionality Reduction

    4.1. LCEM: Linear dimensionality reduction algorithm based on conditional entropy minimization.

    image LCEM algorithm
    Information Theory is a branch of computer science and mathematics that deals with transmission, storage and quantification of information bits. It is also widely used in the field of machine learning to design and optimize algorithms.
    In 2010, Hino and Murata proposed a dimensionality reduction based on class conditional entropy minimization. To look at dimensionality reduction from an information theoretic method, let us define the Shannon Entropy of a random variable X X XX as follows:
    H ( X ) = p ( x ) log p ( x ) d x H ( X ) = p ( x ) log p ( x ) d x H(X)=-int p(x)log p(x)dxH(\boldsymbol{X})=-\int p(\boldsymbol{x}) \log p(\boldsymbol{x}) d \boldsymbol{x} Here, p p pp is the probability density function of X X XX. Now, let us suppose this variable corresponds to data samples in a dataset which also has a class variable (dependent variable) defined by Y Y YY. Given A A AA is a transformation matrix applied on A A AA, then the class-conditonal entropy is given by:
    H ( A T X Y ) = y = 1 C N y N H ( A T X Y = y ) H A T X Y = y = 1 C N y N H A T X Y = y H(A^(T)X∣Y)=sum_(y=1)^(C)(N_(y))/(N)H(A^(T)X∣Y=y)H\left(A^{T} \boldsymbol{X} \mid Y\right)=\sum_{y=1}^{C} \frac{N_{y}}{N} H\left(A^{T} \boldsymbol{X} \mid Y=y\right) Here, N y N y N_(y)N_y is the number of data points in a given class y y yy and N = Σ y = 1 C N y N = Σ y = 1 C N y N=Sigma_(y=1)^(C)N_(y)N =\Sigma^C_{y=1} N_y where y i [ 1 , 2 , . . . , C ] y i [ 1 , 2 , . . . , C ] y_(i)in[1,2,...,C]y_i \in {[1,2,...,C]} is the total number of data points in the dataset. The above formula defines the class conditional entropy of a transformed random variable A T X A T X A^(T)XA^TX. In simple terms, conditional entropy represents how much uncertainty a random variable has remaining if we have already learned the value of a second random variable. This can also be interpreted as the amount of information needed to describe the outcome of a random variable given that the value of another random variable is known. Class conditional entropy, as described above, would imply the amount of uncertainty in the transformed variable A T X A T X A^(T)XA^TX, given the information in the class variable Y Y YY. In this case, since we want to find a transformation that mimics the actual information in X X XX as accurately as possible, without the loss of any information contained, we would want to reduce the uncertainty, and hence minimize the class conditional entropy.
    The method described in this section, constructs a transformation f : x z f : x z f:x|->zf : x \mapsto z which minimizes the class conditional entropy H ( Z | Y ) H ( Z | Y ) H(Z|Y)H(Z|Y). Now, H ( Z | Y ) H ( Z | Y ) H(Z|Y)H(Z|Y ) will be minimized by any functions which map all data x x xx to a single point. We also need to prevent overfitting by avoiding a high representational power of the transformation f f ff. To avoid overfitting in the optimization of H ( Z | Y ) H ( Z | Y ) H(Z|Y)H(Z|Y), we add a regularization term ε Ψ ( f , D ) ε Ψ ( f , D ) epsi Psi(f,D)\varepsilon \Psi(f,D) which depends on both the function f f ff and the given data D D DD:
    min f : x z H ( Z Y ) + ε Ψ ( f , D ) . min f : x z H ( Z Y ) + ε Ψ ( f , D ) . min_(f:x|->z)H(Z∣Y)+epsi Psi(f,D).\min _{f: \boldsymbol{x} \mapsto \boldsymbol{z}} H(\boldsymbol{Z} \mid Y)+\varepsilon \Psi(f, D) . The above function represents the regularized conditional entropy minimization objective.
    The minimization of the class conditional entropy will be done using gradient descent optimization. This means that we calculate the gradient vector of the class conditional entropies of the transformed data z l = a l T x , l = 1 , . . . , m z l = a l T x , l = 1 , . . . , m z_(l)=a_(l)^(T)x,l=1,...,mz_l = a^T_l x, l = 1, . . . , m and update each column of the transformation matrix A A AA.
    Since the objective is to minimize the sum of the marginal entropies, a simple optimization for each marginal entropy may lead us to the same single transformation vector a l = a , ( l = 1 , . . . , m ) a l = a , ( l = 1 , . . . , m ) a_(l)=a,(l=1,...,m)a_l = a, (l = 1, . . . , m) for all the marginal entropies. To avoid this, the authors suggest quasi-orthogonalization to the transformation matrix in each iteration of gradient descent. This is defined in a three-step process as follows:
  • Step 1: Divide A A AA by square root of the largest eigenvalue of A T A A T A A^(T)AA^T A.
  • Step 2: A 3 2 A 1 2 A A T A A 3 2 A 1 2 A A T A A larr(3)/(2)A-(1)/(2)AA^(T)AA \leftarrow \frac{3}{2}A −\frac{1}{2}AA^T A.
  • Step 3: Normalize the norm of each column of A A AA to 1.
  • This optimization process is repeated until the model converges. The result at the end of this process is a converged transformation matrix A A AA. As seen in the figure above, in the gradient step, a marginalized entropy is minimized by gradient descent method for each column of the transformation matrix A A AA, and in the quasi-orthogonalization step, columns of A A AA are quasi-orthogonalized. Thus, this algorithm above uses a linear transformation A T : x z A T : x z A^(T):x|->zA^T: x \mapsto z to decrease the class conditional entropy while reducing the dimensions of the dataset x x xx.
    The same paper as above, also proposes another method of dimensionality reduction: MCEM or Multiple kernel learning algorithm based on conditional entropy minimization.
    image
    The MCEM algorithm is represented in teh image above. THe above technique extends dimensionality reduction using class conditional entropy to non-linear data. It suggests that we combine multiple kernel functions with a coefficient vector β β beta\beta, and optimize this coefficient β β beta\beta along with the weight α α alpha\alpha of the classification function by minimizing the conditional entropy. The detailed explanation of this method can be read in the work published by Hino et al.

    5. Conclusion

    This review only studies a few techniques for dimensionality reduction. There are several other techiques that have been studied in the past. In 2014, Plan et al. studied Dimension Reduction by random hyperplane tessellations. In 2012, Lee et al. published his work and review of graph-based dimension reduction techniques. Neighbourhood components analysis, suggested by Goldberger et al. in 2004 uses Mahalanobis distance measure for dimensionality reduction.

    6. References

    1. Hino, Hideitsu & Murata, Noboru. (2010). A Conditional Entropy Minimization Criterion for Dimensionality Reduction and Multiple Kernel Learning. Neural computation. 22. 2887-923. 10.1162/NECO_a_00027.
    2. Plan, Yaniv & Vershynin, Roman. (2011). Dimension Reduction by Random Hyperplane Tessellations. Discrete and Computational Geometry. 51. 10.1007/s00454-013-9561-6
    3. Lee, John A. & Verleysen, Michel (2012). Graph-based dimensionality reduction (https://perso.uclouvain.be/michel.verleysen/papers/bookLezoray12jl.pdf)
    4. Goldberger, Jacob & Roweis, Sam & Hinton, Geoffrey & Salakhutdinov, Ruslan. (2004). Neighbourhood Components Analysis.. in Advances in Neural Information Processing Systems (NIPS 2004) Vancouver Canada: Dec.. 17.
    5. Principal Component Analysis (https://online.stat.psu.edu/stat505/lesson/11)
    6. Factor Analysis (https://online.stat.psu.edu/stat505/lesson/12)

    Recommended for you

    Eric Mockensturm
    Probing The Full Monty Hall Problem
    Probing The Full Monty Hall Problem
    A tutorial on the Monty Hall problem in statistics.
    8 points
    0 issues