当使用 3 类 时,在 Scikitlearn 的 SVM 中获取决策函数的输出意味着什么
What does the Output means for getting Decision Function in Scikitlearn's SVM, when used 3 classes
我在执行以下代码块 https://prateekvjoshi.com/2015/12/15/how-to-compute-confidence-measure-for-svm-classifiers/ 时参考了以下博客 post,并获得了以下结果。我的目的是在 Scikit-learn 的 SVM 的 SVC 中找出一个点与 3 classes 的距离,但我对所描述的含义感到困惑是否有任何解决方案。
import numpy as np
from sklearn.svm import SVC
x = np.array([[1,2],[2,3],[3,4],[1,4],[1,5],[2,4],[2,6]])
y = np.array([0,1,-1,-1,1,1,0])
classifier = SVC(kernel='linear')
classifier.fit(x,y)
classifier.decision_function([2,1])
最后一次调用给出大小为 3 的数组的以下输出
array([[ -8.88178420e-16, -1.40000000e+00, -1.00000000e+00]])
这个数组是什么意思,我们如何使用这个数组找出三个 class (-1,1,0) 相关的特定数据点。
是点[2,1]
到SVM分类器分离超平面的距离。所以第一个值是 [2,1]
与分隔第一个 class 的超平面的距离,依此类推。您可以查看函数的实现 here and read the documentation here 了解更多信息。
编辑:您也可以查看this example。
我在执行以下代码块 https://prateekvjoshi.com/2015/12/15/how-to-compute-confidence-measure-for-svm-classifiers/ 时参考了以下博客 post,并获得了以下结果。我的目的是在 Scikit-learn 的 SVM 的 SVC 中找出一个点与 3 classes 的距离,但我对所描述的含义感到困惑是否有任何解决方案。
import numpy as np
from sklearn.svm import SVC
x = np.array([[1,2],[2,3],[3,4],[1,4],[1,5],[2,4],[2,6]])
y = np.array([0,1,-1,-1,1,1,0])
classifier = SVC(kernel='linear')
classifier.fit(x,y)
classifier.decision_function([2,1])
最后一次调用给出大小为 3 的数组的以下输出
array([[ -8.88178420e-16, -1.40000000e+00, -1.00000000e+00]])
这个数组是什么意思,我们如何使用这个数组找出三个 class (-1,1,0) 相关的特定数据点。
是点[2,1]
到SVM分类器分离超平面的距离。所以第一个值是 [2,1]
与分隔第一个 class 的超平面的距离,依此类推。您可以查看函数的实现 here and read the documentation here 了解更多信息。
编辑:您也可以查看this example。