[英]Novelty detection using one class svm-python
I'm in the process of novelty detection using machine-learning. 我正在使用机器学习进行新颖性检测。 I have tried using one-class svm in scikit learn .
我已经尝试在scikit learning中使用一类svm。
from sklearn import svm
train_data = [[0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 3, 0, 0, 0, 1, 0, 0], [0, 11, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 4]]
test_data = [[0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0]]
clf = svm.OneClassSVM(nu=0.1, kernel="rbf", gamma=0.1)
clf.fit(train_data)
pred_test = clf.predict(test_data)
I'm new to this area and I want to know how can I say there is novelty in my test data? 我是该领域的新手,我想知道如何说测试数据中有新颖性?
The inliers are labeled 1, and the outliers (ie, the novelties in your case) are labeled -1 (as the result of the predict
function). 离群值标记为1,离群值(即您情况下的新颖性)标记为-1(作为
predict
函数的结果)。
Please notice that the current documentation incorrectly states that the outliers are labeled 1 & inliers are labeled 0. Please check out the latest updates on github repo for the correct information. 请注意, 当前文档错误地指出异常值标记为1,而异常值标记为0。请查看github repo上的最新更新以获取正确的信息。
check = clf.predict(test_data) 检查= clf.predict(test_data)
if check = 1 then not anomaly and 如果check = 1,则不是异常,并且
if check = -1 then it an anomaly ie data is outlier 如果check = -1,则表示异常,即数据异常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.