1
$\begingroup$

I am trying to do the 2-class classification using regularized discriminant analysis in Matlab using fitdiscr() function. The coefficients are stored in the object created by created by fitdiscr(). But the coefficients are stored in a 2x2 cell, shouldn't there be just one coefficients vector for any given discriminant analysis problem?

load('AA.mat')
obj = fitcdiscr(AA',actual_group','SaveMemory','on','FillCoeffs','on')

The coefficients are stored in obj.Coeffs.

Here is the data that I am using, first 10 columns belong to class-0 and last 10 column belong to class-1.

$\endgroup$
  • $\begingroup$ each element of obj.Coeffs is a 2000X1 vector its not possible to show it here $\endgroup$ – Spandy Dec 1 '15 at 17:37
3
$\begingroup$

You are correct that only one set of coefficients is necessary here. But the function can also handle more than just binary classification, so the storage arrangement is general enough to handle that.

You should find that the (1,1) coefficients are empty, and the (1,2) coefficients match the (2,1) coefficients but with opposite sign. Of course for a three-class problem there would also be (1,3) and (2,3) coefficients that are not redundant with the (1,2) coefficients.

If I try this:

C = c.Coeffs(1,2).Const;
L = c.Coeffs(1,2).Linear;
score = C + x*L

I see that high scores favor class 1 over class 2. The inverse logit transformation converts the scores to probabilities.

x = [4 3 2 1];
x =
     4     3     2     1
[~,score] = predict(c,x)
score =
    0.5884    0.4116    0.0000
1./(1+exp(-C-x*L))
ans =
    0.5884
$\endgroup$
  • $\begingroup$ So given a new test data ,with which coefficient vector should I do the dot product with ((1,2) or (2,1)?) to obtain posterior predictive score ? $\endgroup$ – Spandy Dec 1 '15 at 19:08
  • $\begingroup$ I edited the answer to include this information. $\endgroup$ – Tom Lane Dec 2 '15 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.