Can someone tell me if there is an error in fitcdiscr function?
Show older comments
I think the fitcdiscr function has error(s). I tested both the quadratic discrimination option:
rng('default'); X = rand(40,2); GroupLabels = randsample({'HC','MCI'}, 40, true)'; Cost0 = [0 1; 1 0];
DAC = fitcdiscr(X, GroupLabels, 'DiscrimType', 'quadratic', 'Cost', Cost0);
K = DAC.Coeffs(1,2).Const;
L = DAC.Coeffs(1,2).Linear;
Q = DAC.Coeffs(1,2).Quadratic;
and the linear augmented option that reproduce the same quadratic fit:
X1 = X(:,1); X2 = X(:,2); X3 = X1.*X1; X4 = X1.*X2; X5 = X2.*X2;
tbl = table(GroupLabels, X1, X2, X3, X4, X5);
DAC2 = fitcdiscr(tbl, 'GroupLabels ~ X1 + X2 + X3 + X4 + X5', 'Cost', Cost0);
K2 = DAC2.Coeffs(1,2).Const;
L2 = DAC2.Coeffs(1,2).Linear;
Please check the values of K,L,Q and K2,L2. They don't match, not even close and fitting is very differenct between both classifiers.
Also, I think that fitcdiscr is not reading or using properly the specified formula. Previously, I had used the declaration:
DAC2 = fitcdiscr(tbl, 'GroupLabels ~ X1 + X2 + X3 + X5 + X4', 'Cost', Cost0);
That is, switching the 4th and 5th predictors, and the coefficient values were the same in the same order.
But that is wrong (in my opinion) cause coefficients 4th and 5th are now inverted!
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Discriminant Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!