Linear Discriminant Analysis
no vote
% LDA - MATLAB subroutine to perform linear discriminant analysis % Use: % W = LDA(Input,Target,Priors) % % W = discovered linear coefficients (first column is the constants) % Input = predictor data (variables in columns, observations in rows) % Target = target variable (class labels) % Priors = vector of prior probabilities (optional) % % Note: discriminant coefficients are stored in W in the order of unique(Target) % % Example: % % % Generate example data: 2 groups, of 10 and 15, respectively % X = [randn(10,2); randn(15,2) + 1.5]; Y = [zeros(10,1); ones(15,1)]; % % % Calculate linear discriminant coefficients % W = LDA(X,Y); % % % Calulcate linear scores for training data % L = [ones(25,1) X] * W'; % % % Calculate class prob