Click to Chat

1800-2000-838

+91-120-4616500

CART 0

• 0

MY CART (5)

Use Coupon: CART20 and get 20% off on all online Study Material

ITEM
DETAILS
MRP
DISCOUNT
FINAL PRICE
Total Price: Rs.

There are no items in this cart.
Continue Shopping
`        function of LDA with support of an example`
7 years ago

Komal
747 Points
```										Linear Discriminant Analysis (LDA)The basic idea of LDA is simple: for each class to be identified, calculate a (different) linear function of the attributes. The class function yielding the highest score represents the predicted class.There are many linear classification models, and they differ largely in how the coefficients are established. One nice quality of LDA is that, unlike some of the alternatives, it does not require multiple passes over the data for optimization. Also, it naturally handles problems with more than two classes and it can provide probability estimates for each of the candidate classes.Some analysts attempt to interpret the signs and magnitudes of the coefficients of the linear scores, but this can be tricky, especially when the number of classes is greater than 2.LDA bears some resemblance to principal components analysis (PCA), in that a number of linear functions are produced (using all raw variables), which are intended, in some sense, to provide data reduction through rearrangement of information. (See the Feb-26-2010 posting to this log,Principal Components Analysis.) Note, though, some important differences: First, the objective of LDA is to maximize class discrimination, whereas the objective of PCA is to squeeze variance into as few components as possible. Second, LDA produces exactly as many linear functions as there are classes, whereas PCA produces as many linear functions as there are original variables. Last, principal components are always orthogonal to each other ("uncorrelated"), while that is not generally true for LDA's linear scores.Note that theLDAfunction assumes that the data its being fed is complete (no missing values) and performs no attribute selection.Use ofLDAis straightforward: the programmer supplies the input and target variables and, optionally, prior probabilities. The function returns the fitted linear discriminant coefficients. a good example:% Generate example data: 2 groups, of 10 and 15, respectivelyX = [randn(10,2); randn(15,2) + 1.5]; Y = [zeros(10,1); ones(15,1)];% Calculate linear discriminant coefficientsW = LDA(X,Y);This example randomly generates an artificial data set of two classes (labeled 0 and 1) and two input variables. The LDA function fits linear discriminants to the data, and stores the result inW. So, what is inW?take a look:>> WW =-1.1997 0.2182 0.6110-2.0697 0.4660 1.4718The first row contains the coefficients for the linear score associated with the first class (this routine orders the linear functions the same way asunique()). In this model, -1.1997 is the constant and 0.2182 and 0.6110 are the coefficients for the input variables for the first class (class 0). Coefficients for the second class's linear function are in the second row. Calculating the linear scores is easy:% Calulcate linear scores for training dataL = [ones(25,1) X] * W';Each column represents the output of the linear score for one class. In this case, the first column is class 0, and the second column is class 1. For any given observation, the higher the linear score, the more likely that class. Note that LDA's linear scores are not probabilities, and may even assume negative values. Here are the values from my run:>> LL =-1.9072 -3.80601.0547 3.2517-1.2493 -2.0547-1.0502 -1.7608-0.6935 -0.8692-1.6103 -2.9808-1.3702 -2.4545-0.2148 0.28250.4419 1.67170.2704 1.30671.0694 3.2670-0.0207 0.7529-0.2608 0.06011.2369 3.6135-0.8951 -1.45420.2073 1.16870.0551 0.82040.1729 1.16540.2993 1.4344-0.6562 -0.80280.2195 1.2068-0.3070 0.05980.1944 1.26280.5354 2.06890.0795 1.0976To obtain estimated probabilities, simply run the linear scores through the softmax transform (exponentiate everything, and normalize so that they sum to 1.0):% Calculate class probabilitiesP = exp(L) ./ repmat(sum(exp(L),2),[1 2]);As we see, most of the first 10 cases exhibit higher probabilities for class 0 (the first column) than for class 1 (the second column) and the reverse is true for the last 15 cases:>> PP =0.8697 0.13030.1000 0.90000.6911 0.30890.6705 0.32950.5438 0.45620.7975 0.20250.7473 0.25270.3782 0.62180.2262 0.77380.2619 0.73810.1000 0.90000.3157 0.68430.4205 0.57950.0850 0.91500.6363 0.36370.2766 0.72340.3175 0.68250.2704 0.72960.2432 0.75680.5366 0.46340.2714 0.72860.4093 0.59070.2557 0.74430.1775 0.82250.2654 0.7346This model is not perfect, and would really need to be tested more rigorously (via holdout testing, k-fold cross validation, etc.) to determine how well it approximates the data.will not demonstrate its use here, but theLDAroutine offers a facility for modifying the prior probabilities. Briefly, the function assumes that the true distribution of classes is whatever it observes in the training data. Analysts, however, may wish to adjust this distribution for several reasons, and the third, optional, parameter allows this. Note that the LDA routine presented here always performs the adjustment for prior probabilities: Some statistical software drops the adjustment for prior probabilities altogether if the user specifies that classes are equally likely, and will produce different results thanLDA.
```
2 years ago
Think You Can Provide A Better Answer ?

## Other Related Questions on Organic Chemistry

View all Questions »
• Complete JEE Main/Advanced Course and Test Series
• OFFERED PRICE: Rs. 15,900
• View Details