scikit中的OCSVM:离群点的距离总是负的

2024-09-29 01:19:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用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的样本总是显示负距离。在

我以为距离没有标志,因为它与方向无关。我想了解在OneClassSVscikit分类器中是如何计算距离的。符号是否仅仅表示样本位于支持向量机计算的决策超平面之外?在

请帮忙。在


Tags: 数据标记距离分类器functionscikitnu样本
1条回答
网友
1楼 · 发布于 2024-09-29 01:19:25

sklearn's OneClassSVM由以下paper实现,如here所述:

Bernhard Schölkopf, John C. Platt, John C. Shawe-Taylor, Alex J. Smola, and Robert C. Williamson. 2001. Estimating the Support of a High-Dimensional Distribution. Neural Comput. 13, 7 (July 2001), 1443-1471. DOI: https://doi.org/10.1162/089976601750264965

让我们看看那张纸的摘要here

Suppose you are given some data set drawn from an underlying probability distribution P and you want to estimate a “simple” subset S of input space such that the probability that a test point drawn from P lies outside of S equals some a priori specied value between 0 and 1.

We propose a method to approach this problem by trying to estimate a function f that is positive on S and negative on the complement.

因此,本文的摘要定义了OneClassSVM的函数f,后面跟着sklearn。在

相关问题 更多 >