![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173554/image.bmp)
Plotting 3 Dimensional Class boundaries of LDA in Matlab
19 ビュー (過去 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/173554/image.bmp)
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!