Error in plotting decision boundaries using Linear Discriminant Analysis (LDA)?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi ! I am trying to plot decision boundaries of a 3 class classification problem using LDA.
MATLAB already has solved and posted a 3 class IRIS FLOWER classification problem. I am also using the same code that MATLAB has used to plot decision boundaries BUT I am unable to do so. I have attached both files that can be used to run and test the program.
The IRIS FLOWER example code is taken from
clear all
clc
load('features.mat')
load('labels.mat')
%Originally there are multiple features and 10 classes. I am using only first 3 classes.
Train_Features=Train_Features(1:61*3,:);
Train_Labels=Train_Labels(1:61*3,:);
%Originally there are multiple features but I am using only feature 4 and feature 5.
PL = Train_Features(:,5);
PW = Train_Features(:,4);
h1 = gscatter(PW,PL,Train_Labels,'krb','ov^',[],'off');
h1(1).LineWidth = 2;
h1(2).LineWidth = 2;
h1(3).LineWidth = 2;
legend('Open Hand','Close Hand','Flex','Location','best')
hold on

Till HERE, everything is fine.
X = [PL,PW];
MdlLinear = fitcdiscr(X,Train_Labels);
K = MdlLinear.Coeffs(2,3).Const;
L = MdlLinear.Coeffs(2,3).Linear;
f = @(x1,x2) K + L(1)*x1 + L(2)*x2;
h2 = fimplicit(f,[0 1 90 400]);
h2.Color = 'r';
h2.LineWidth = 2;
h2.DisplayName = 'Boundary between Close Hand & Flex Hand';
MdlLinear.ClassNames([1 2])
K = MdlLinear.Coeffs(1,2).Const;
L = MdlLinear.Coeffs(1,2).Linear;
f = @(x1,x2) K + L(1)*x1 + L(2)*x2;
h3 = fimplicit(f,[0 1 90 400]);
h3.Color = 'k';
h3.LineWidth = 2;
h3.DisplayName = 'Boundary between Open Hand & Close Hand';
axis([0 1 90 400])
xlabel('Number of SSC features')
ylabel('Number of MAV features')

HERE it does not shows the decision boundaries. Any HELP?
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Classification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!