Home How to plot fitcsvm() results using two first principal components of pca on 2D MATLAB
Reply: 0

How to plot fitcsvm() results using two first principal components of pca on 2D MATLAB

user1139
1#
user1139 Published in April 23, 2018, 8:58 pm

I am using:

SvmModel= fitcsvm(X,Y);

to build an SVM model and I want to plot the resulting hyper plane in 2D. I am having trouble understanding the structure of the results I am getting. For x with 30 features over 455 samples (~80% breast cancer dataset) I was expecting a 30 by w vector plus a 1 by 1 b vector. I can only find the SVMModel.W variable which is 455 by 1.

I am trying to plot the output on a 2D space using pca in the wollowing way:

[coeff, score, ~, ~, ~, mu]=pca(X);
gscatter(score(:,1),score(:,2),Y,'br','.');
hold on; 

plot(score(SvmModel.IsSupportVector,1),...
score(SvmModel.IsSupportVector,2),'go');
%project and plot hyper plane
hold off;

In the commented line I want to project and plot the hyper plane.I have seen this answer for the 2D case, as well as, this answer for the 3D case. My problem has 30D and needs to be projected into 2D.

  • How do I make scence of the output?
  • How do I project the results on a 2D plain using 2 first PCA components?
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309878 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO