我使用Scikit中的单类SVM分类器OneClassSVM
来确定数据集中的异常值。我的数据集有30000个样本,有1024个变量。我用其中的10%作为培训数据。在
clf=svm.OneClassSVM(nu=0.001,kernel="rbf",gamma=1e-5)
clf.fit(trset)
dist2hptr=clf.decision_function(trset)
tr_y=clf.predict(trset)
如上所述,我使用decision_function(x)
函数计算每个样本到决策函数的距离。当我比较预测结果和距离结果时,预测输出中标记为+1的样本总是显示正距离,而标记为-1的样本总是显示负距离。在
我以为距离没有标志,因为它与方向无关。我想了解在OneClassSV
scikit分类器中是如何计算距离的。符号是否仅仅表示样本位于支持向量机计算的决策超平面之外?在
请帮忙。在
sklearn's OneClassSVM由以下paper实现,如here所述:
让我们看看那张纸的摘要here:
因此,本文的摘要定义了OneClassSVM的函数
f
,后面跟着sklearn。在相关问题 更多 >
编程相关推荐