我使用python中的libsvm(svmutils)进行分类任务。分类器是准确的。但是,我得到这样的输出:
*
optimization finished, #iter = 75
nu = 0.000021
obj = -0.024330, rho = 0.563710
nSV = 26, nBSV = 0
Total nSV = 26
*
optimization finished, #iter = 66
nu = 0.000030
obj = -0.035536, rho = -0.500676
nSV = 21, nBSV = 0
Total nSV = 21
*
optimization finished, #iter = 78
nu = 0.000029
obj = -0.033921, rho = -0.543311
nSV = 23, nBSV = 0
Total nSV = 23
*
optimization finished, #iter = 90
nu = 0.000030
obj = -0.035333, rho = -0.634721
nSV = 23, nBSV = 0
Total nSV = 23
Accuracy = 0% (0/1) (classification)
Accuracy = 0% (0/1) (classification)
Accuracy = 0% (0/1) (classification)
Accuracy = 0% (0/1) (classification)
有什么方法可以抑制这个对话框吗?分类器非常好,我很好奇。另外,"Accuracy"
代表什么?为什么在我的情况下这是0%? (数据在80个维度中不重叠。总共4个类。我也正确地将其标准化。)
答案 0 :(得分:4)
使用-q
参数选项
import svmutil
param = svmutil.svm_parameter('-q')
...
或
import svmutil
x = [[0.2, 0.1], [0.7, 0.6]]
y = [0, 1]
svmutil.svm_train(y, x, '-q')
答案 1 :(得分:1)
这可行:
import sys
from StringIO import StringIO
# back up your standard output
bkp_stdout = sys.stdout
# replace standard output with dummy stream
sys.stdout = StringIO()
print 1 # here you should put you call (classification)
#restore standard output for further use
sys.stdout = bkp_stdout
print 2
此外,在分类问题中,准确度是使用训练模型从测试/交叉验证集中正确预测项目的一部分(百分比)。
答案 2 :(得分:1)
要抑制训练和预测输出,您需要结合has2k1(用于抑制训练输出)和vonPetrushev(用于抑制预测输出)提供的解决方案。
不幸的是,您无法执行以下操作:
# Test matrix built, execute prediction.
paramString = "" if useVerbosity else " -q "
predLabels, predAccuracy, predDiscriminants = \
svmutil.svm_predict( targetLabels, testData, svModel.representation, paramString )
因为使用当前的python接口,您将收到以下错误:
File "/home/jbbrown/local_bin/pyLibSVM/pyLibSVM/svmutil.py", line 193, in svm_predict
raise ValueError("Wrong options")
ValueError: Wrong options