我可以使用 Scikit learn 绘制 3 个特征(在 3D 空间中)的 SVM 决策边界吗? [英] Can I plot the SVM decision boundary for 3 features(in 3D space) using Scikit learn?

查看:39
本文介绍了我可以使用 Scikit learn 绘制 3 个特征(在 3D 空间中)的 SVM 决策边界吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 scikit-learn 来理解支持向量机 (SVM).我想绘制由 SVM 计算的决策边界.SVM 使用 3 个特征.所以决策边界必须在 3D 空间中绘制.这可以使用 scikit-learn 吗?我在官方网站上只能找到 SVM 决策边界的二维图.但是我在 stackoverflow 上找到了链接,这表明使用 matlabr.有没有办法使用 scikit-learn 实现相同的目标?

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?

推荐答案

您不使用 scikit-learn 在 Python 中绘制事物.你必须使用另一个包,如果你检查 scikit-learn 的例子,你会看到它们使用 matplotlib.您可以使用 matplotlib 创建 3D 图,这里是教程.用法与 2D 中基本相同,只是您为第三维添加了一个参数.

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.

您可以使用的另一个流行软件包是 mayavi,它专为3D 绘图.

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

这篇关于我可以使用 Scikit learn 绘制 3 个特征(在 3D 空间中)的 SVM 决策边界吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆