Error in plotting decision boundaries using Linear Discriminant Analysis (LDA)?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!