
Plotting 3 Dimensional Class boundaries of LDA in Matlab
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi guys, I'm doing some classification research and looking into LDA. For now I'm researching Fisher's iris Data that id built into matlab. I understand when it is 2 dimensional the plotting of the boundary lines is quite straight forward. However if I use 3 dimensions I'm not quite sue how to plot the boundary lines. I've used the example on mathworks, for 2-dimensions and this is not a problem (<http://uk.mathworks.com/help/stats/discriminant-analysis.html)>.
I've attached a matlab plot of the 3 features I'm looking to use from the data, what I'm looking to get is a plane across the 3 features that separates the data into its different classes, in this example I'd need 2 planes. This is what is used for 2D
endMdlLinear.ClassNames([2 3])
K = MdlLinear.Coeffs(2,3).Const;
L = MdlLinear.Coeffs(2,3).Linear;
f = @(x1,x2) K + L(1)*x1 + L(2)*x2;
h2 = ezplot(f,[.9 7.1 0 2.5]);
h2.Color = 'r';
h2.LineWidth = 2;
Any help would be appreciated.
댓글 수: 0
답변 (1개)
Omanshu Thapliyal
2017년 3월 28일
It would be recommended to use fsurf instead of 'ezplot' as it would help you plot a 3d plane, as you require.
Assuming that you have 2 Gaussian random vectors X1 and x2, here's how you could perform LDA and then plots a discriminant plane between the two sets.
X = [X1;X2];
MdlLinear = fitcdiscr(X,c);
K = MdlLinear.Coeffs(1,2).Const;
L = MdlLinear.Coeffs(2,1).Linear;
f = @(x1,x2) K + L(1)*x1 + L(2)*x2;
fsurf(f,'FaceColor',[1 0 0],'EdgeColor','none');
alpha = 0.5;
The script above produces the plot attached:

댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!