Can I plot the SVM decision boundary for 3 features(in 3D space) using Scikit learn?

荒凉一梦 提交于 2019-12-24 05:24:05

问题


I am using scikit-learn to understand Support Vector Machines(SVM). I want to plot the decision boundary computed by SVM. The SVM uses 3 features. So the decision boundary must be drawn in 3D space. Is this possible using scikit-learn? I could find only 2D plots of SVM decision boundary at the official website. However I found links on stackoverflow which show this is possible using matlab and r. Is there a way in which I can achieve the same using scikit-learn?


回答1:


You don't use scikit-learn to plot things in Python. You have to use another package, and if you check scikit-learn's examples, you will see they use matplotlib. You can create 3D plots with matplotlib, here is the tutorial. The usage is basically the same than in 2D, except you add an argument for the third dimension.

Another popular package you could use is mayavi, which was conceived especially for 3D plotting.



来源:https://stackoverflow.com/questions/29918559/can-i-plot-the-svm-decision-boundary-for-3-featuresin-3d-space-using-scikit-le

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!