Linear discriminant analysis
Linear discriminant analysis (LDA), normal discriminant analysis (NDA), or discriminant function analysis is a generalization of Fisher's linear discriminant, a method used in statistics and other fields, to find a linear combination of features that characterizes or separates two or more classes of objects or events. The resulting combination may be used as a linear classifier, or, more commonly, for dimensionality reduction before later classification. LDA is closely related to analysis of variance (ANOVA) and regression analysis, which also attempt to express one dependent variable as a linear combination of other features or measurements. However, ANOVA  uses categorical independent variables and a continuous dependent variable, whereas discriminant analysis has continuous independent variables and a categorical dependent variable ("i.e." the class label). Logistic regression and probit regression are more similar to LDA than ANOVA is, as they also explain a categorical variable by the values of continuous independent variables. These other methods are preferable in applications where it is not reasonable to assume that the independent variables are normally distributed, which is a fundamental assumption of the LDA method. LDA is also closely related to principal component analysis (PCA) and factor analysis in that they both look  for linear combinations of variables which best explain the data. LDA explicitly attempts to model the difference between the classes of data. PCA, in contrast, does not take into account any difference in class, and factor analysis builds the feature combinations based on differences rather than similarities. Discriminant analysis is also different from factor analysis in that it is not an interdependence technique: a distinction between independent variables and dependent variables (also called criterion variables) must be made. LDA works when the measurements made on independent variables for each observation are continuous quantities. When dealing with categorical independent variables, the  equivalent technique is discriminant correspondence analysis. Discriminant analysis is used when groups are known a priori (unlike in cluster analysis). Each case must have a score on one or more quantitative predictor measures, and a score on a group measure. In simple terms, discriminant function analysis is classification - the act of distributing things into groups, classes or categories of the same type. History. The original dichotomous discriminant analysis was developed by Sir Ronald Fisher in 1936. It is different from an ANOVA or MANOVA, which is used to predict one (ANOVA) or multiple (MANOVA) continuous dependent variables by one or  more independent categorical variables. Discriminant function analysis is useful in determining whether a set of variables is effective in predicting category membership. LDA for two classes. Consider a set of observations formula_1 (also called features, attributes, variables or measurements) for each sample of an object or event with known class formula_2. This set of samples is called the training set. The classification problem is then to find a good predictor for the class formula_2 of any sample of the same distribution (not necessarily from the training set) given only an observation formula_4. LDA approaches the problem by assuming that the  conditional probability density functions formula_5 and formula_6 are both the normal distribution with mean and covariance parameters formula_7 and formula_8, respectively. Under this assumption, the Bayes optimal solution is to predict points as being from the second class if the log of the likelihood ratios is bigger than some threshold T, so that: Without any further assumptions, the resulting classifier is referred to as quadratic discriminant analysis (QDA). LDA instead makes the additional simplifying homoscedasticity assumption ("i.e." that the class covariances are identical, so formula_10) and that the covariances have full rank. In this case, several terms cancel: and the  above decision criterion becomes a threshold on the dot product for some threshold constant "c", where This means that the criterion of an input formula_17 being in a class formula_2 is purely a function of this linear combination of the known observations. It is often useful to see this conclusion in geometrical terms: the criterion of an input formula_17 being in a class formula_2 is purely a function of projection of multidimensional-space point formula_17 onto vector formula_22 (thus, we only consider its direction). In other words, the observation belongs to formula_2 if corresponding formula_17 is located on a certain  side of a hyperplane perpendicular to formula_22. The location of the plane is defined by the threshold c. Assumptions. The assumptions of discriminant analysis are the same as those for MANOVA. The analysis is quite sensitive to outliers and the size of the smallest group must be larger than the number of predictor variables. It has been suggested that discriminant analysis is relatively robust to slight violations of these assumptions, and it has also been shown that discriminant analysis may still be reliable when using dichotomous variables (where multivariate normality is often violated). Discriminant functions. Discriminant analysis works by creating  one or more linear combinations of predictors, creating a new latent variable for each function. These functions are called discriminant functions. The number of functions possible is either formula_26 where formula_27 = number of groups, or formula_28 (the number of predictors), whichever is smaller. The first function created maximizes the differences between groups on that function. The second function maximizes differences on that function, but also must not be correlated with the previous function. This continues with subsequent functions with the requirement that the new function not be correlated with any of the previous functions. Given group formula_29, with formula_30  sets of sample space, there is a discriminant rule such that if formula_31, then formula_32. Discriminant analysis then, finds “good” regions of formula_30 to minimize classification error, therefore leading to a high percent correct classified in the classification table. Each function is given a discriminant score to determine how well it predicts group placement. Eigenvalues. An eigenvalue in discriminant analysis is the characteristic root of each function. It is an indication of how well that function differentiates the groups, where the larger the eigenvalue, the better the function differentiates. This however, should be interpreted with caution, as eigenvalues have no  upper limit. Effect size. Some suggest the use of eigenvalues as effect size measures, however, this is generally not supported. Instead, the canonical correlation is the preferred measure of effect size. It is similar to the eigenvalue, but is the square root of the ratio of "SS" and "SS". It is the correlation between groups and the function. Canonical discriminant analysis for "k" classes. Canonical discriminant analysis (CDA) finds axes ("k" − 1 canonical coordinates, "k" being the number of classes) that best separate the categories. These linear functions are uncorrelated and define, in effect, an optimal "k" − 1  space through the "n"-dimensional cloud of data that best separates (the projections in that space of) the "k" groups. See “Multiclass LDA” for details below. Fisher's linear discriminant. The terms "Fisher's linear discriminant" and "LDA" are often used interchangeably, although Fisher's original article actually describes a slightly different discriminant, which does not make some of the assumptions of LDA such as normally distributed classes or equal class covariances. Suppose two classes of observations have means formula_36 and covariances formula_37. Then the linear combination of features formula_38 will have means formula_39 and variances formula_40 for formula_41. Fisher defined  the separation between these two distributions to be the ratio of the variance between the classes to the variance within the classes: This measure is, in some sense, a measure of the signal-to-noise ratio for the class labelling. It can be shown that the maximum separation occurs when When the assumptions of LDA are satisfied, the above equation is equivalent to LDA. Be sure to note that the vector formula_44 is the normal to the discriminant hyperplane. As an example, in a two dimensional problem, the line that best divides the two groups is perpendicular to formula_44. Generally , the data points to be discriminated are projected onto formula_44; then the threshold that best separates the data is chosen from analysis of the one-dimensional distribution. There is no general rule for the threshold. However, if projections of points from both classes exhibit approximately the same distributions, a good choice would be the hyperplane between projections of the two means, formula_47 and formula_48. In this case the parameter c in threshold condition formula_14 can be found explicitly: Otsu's method is related to Fisher's linear discriminant, and was created to binarize the histogram of pixels in a grayscale  image by optimally picking the black/white threshold that minimizes intra-class variance and maximizes inter-class variance within/between grayscales assigned to black and white pixel classes. Multiclass LDA. In the case where there are more than two classes, the analysis used in the derivation of the Fisher discriminant can be extended to find a subspace which appears to contain all of the class variability. This generalization is due to C. R. Rao. Suppose that each of C classes has a mean formula_51 and the same covariance formula_52. Then the scatter between class variability may be defined by the  sample covariance of the class means where formula_54 is the mean of the class means. The class separation in a direction formula_55 in this case will be given by This means that when formula_55 is an eigenvector of formula_58 the separation will be equal to the corresponding eigenvalue. If formula_58 is diagonalizable, the variability between features will be contained in the subspace spanned by the eigenvectors corresponding to the "C" − 1 largest eigenvalues (since formula_60 is of rank "C" − 1 at most). These eigenvectors are primarily used in feature reduction, as in PCA. The eigenvectors corresponding to the  smaller eigenvalues will tend to be very sensitive to the exact choice of training data, and it is often necessary to use regularisation as described in the next section. If classification is required, instead of dimension reduction, there are a number of alternative techniques available. For instance, the classes may be partitioned, and a standard Fisher discriminant or LDA used to classify each partition. A common example of this is "one against the rest" where the points from one class are put in one group, and everything else in the other, and then LDA applied. This will result in C  classifiers, whose results are combined. Another common method is pairwise classification, where a new classifier is created for each pair of classes (giving "C"("C" − 1)/2 classifiers in total), with the individual classifiers combined to produce a final classification. Incremental LDA. The typical implementation of the LDA technique requires that all the samples are available in advance. However, there are situations where the entire data set is not available and the input data are observed as a stream. In this case, it is desirable for the LDA feature extraction to have the ability to update the computed LDA features by  observing the new samples without running the algorithm on the whole data set. For example, in many real-time applications such as mobile robotics or on-line face recognition, it is important to update the extracted LDA features as soon as new observations are available. An LDA feature extraction technique that can update the LDA features by simply observing new samples is an "incremental LDA algorithm", and this idea has been extensively studied over the last two decades. Chatterjee and Roychowdhury proposed an incremental self-organized LDA algorithm for updating the LDA features. In other work, Demir and Ozmehmet proposed  online local learning algorithms for updating LDA features incrementally using error-correcting and the Hebbian learning rules. Later, Aliyari "et a"l. derived fast incremental algorithms to update the LDA features by observing the new samples. Practical use. In practice, the class means and covariances are not known. They can, however, be estimated from the training set. Either the maximum likelihood estimate or the maximum a posteriori estimate may be used in place of the exact value in the above equations. Although the estimates of the covariance may be considered optimal in some sense, this does not mean that the resulting  discriminant obtained by substituting these values is optimal in any sense, even if the assumption of normally distributed classes is correct. Another complication in applying LDA and Fisher's discriminant to real data occurs when the number of measurements of each sample (i.e., the dimensionality of each data vector) exceeds the number of samples in each class. In this case, the covariance estimates do not have full rank, and so cannot be inverted. There are a number of ways to deal with this. One is to use a pseudo inverse instead of the usual matrix inverse in the above  formulae. However, better numeric stability may be achieved by first projecting the problem onto the subspace spanned by formula_60. Another strategy to deal with small sample size is to use a shrinkage estimator of the covariance matrix, which can be expressed mathematically as where formula_63 is the identity matrix, and formula_64 is the "shrinkage intensity" or "regularisation parameter". This leads to the framework of regularized discriminant analysis or shrinkage discriminant analysis. Also, in many practical cases linear discriminants are not suitable. LDA and Fisher's discriminant can be extended for use in non-linear classification via the kernel trick. Here , the original observations are effectively mapped into a higher dimensional non-linear space. Linear classification in this non-linear space is then equivalent to non-linear classification in the original space. The most commonly used example of this is the kernel Fisher discriminant. LDA can be generalized to multiple discriminant analysis, where "c" becomes a categorical variable with "N" possible states, instead of only two. Analogously, if the class-conditional densities formula_65 are normal with shared covariances, the sufficient statistic for formula_66 are the values of "N" projections, which are the subspace spanned by the "N" means, affine projected by  the inverse covariance matrix. These projections can be found by solving a generalized eigenvalue problem, where the numerator is the covariance matrix formed by treating the means as the samples, and the denominator is the shared covariance matrix. See “Multiclass LDA” above for details. Applications. In addition to the examples given below, LDA is applied in positioning and product management. Bankruptcy prediction. In bankruptcy prediction based on accounting ratios and other financial variables, linear discriminant analysis was the first statistical method applied to systematically explain which firms entered bankruptcy vs. survived. Despite limitations including known nonconformance of accounting ratios to  the normal distribution assumptions of LDA, Edward Altman's 1968 model is still a leading model in practical applications. Face recognition. In computerised face recognition, each face is represented by a large number of pixel values. Linear discriminant analysis is primarily used here to reduce the number of features to a more manageable number before classification. Each of the new dimensions is a linear combination of pixel values, which form a template. The linear combinations obtained using Fisher's linear discriminant are called "Fisher faces", while those obtained using the related principal component analysis are called "eigenfaces". Marketing. In marketing , discriminant analysis was once often used to determine the factors which distinguish different types of customers and/or products on the basis of surveys or other forms of collected data. Logistic regression or other methods are now more commonly used. The use of discriminant analysis in marketing can be described by the following steps: Biomedical studies. The main application of discriminant analysis in medicine is the assessment of severity state of a patient and prognosis of disease outcome. For example, during retrospective analysis, patients are divided into groups according to severity of disease – mild, moderate and severe form. Then results of  clinical and laboratory analyses are studied in order to reveal variables which are statistically different in studied groups. Using these variables, discriminant functions are built which help to objectively classify disease in a future patient into mild, moderate or severe form. In biology, similar principles are used in order to classify and define groups of different biological objects, for example, to define phage types of Salmonella enteritidis based on Fourier transform infrared spectra, to detect animal source of Escherichia coli studying its virulence factors etc. Earth science. This method can be used to . For example, when different data from various  zones are available, discriminant analysis can find the pattern within the data and classify it effectively. Comparison to logistic regression. Discriminant function analysis is very similar to logistic regression, and both can be used to answer the same research questions. Logistic regression does not have as many assumptions and restrictions as discriminant analysis. However, when discriminant analysis’ assumptions are met, it is more powerful than logistic regression. Unlike logistic regression, discriminant analysis can be used with small sample sizes. It has been shown that when sample sizes are equal, and homogeneity of variance/covariance holds, discriminant analysis is more accurate . Despite all these advantages, logistic regression has none-the-less become the common choice, since the assumptions of discriminant analysis are rarely met. Linear discriminant in high dimension. Geometric anomalies in higher dimensions lead to the well-known curse of dimensionality. Nevertheless, proper utilization of concentration of measure phenomena can make computation easier. An important case of these "blessing of dimensionality" phenomena was highlighted by Donoho and Tanner: if a sample is essentially high-dimensional then each point can be separated from the rest of the sample by linear inequality, with high probability, even for exponentially large samples. These linear  inequalities can be selected in the standard (Fisher's) form of the linear discriminant for a rich family of probability distribution. In particular, such theorems are proven for log-concave distributions including multidimensional normal distribution (the proof is based on the concentration inequalities for log-concave measures) and for product measures on a multidimensional cube (this is proven using Talagrand's concentration inequality for product probability spaces). Data separability by classical linear discriminants simplifies the problem of error correction for artificial intelligence systems in high dimension.