4

分類タスクに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つのクラスです。また、適切に正規化しています。)

4

3 に答える 3

6

-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')
于 2012-01-31T02:48:53.717 に答える
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

また、分類問題では、精度は、トレーニング済みモデルを使用したテスト/クロス検証セットから正しく予測されたアイテムの一部 (パーセンテージ) です。

于 2011-11-28T23:09:28.530 に答える
1

To suppress both training and prediction output, you will need to combine the solutions provided by has2k1 (for suppressing training output) and vonPetrushev (for suppressing prediction output).

Unfortunately, you cannot do something like the following:

# Test matrix built, execute prediction.
paramString = "" if useVerbosity else " -q "
predLabels, predAccuracy, predDiscriminants = \
 svmutil.svm_predict( targetLabels, testData, svModel.representation, paramString )

Because with the current python interface you will get the following error:

  File "/home/jbbrown/local_bin/pyLibSVM/pyLibSVM/svmutil.py", line 193, in svm_predict
    raise ValueError("Wrong options")
  ValueError: Wrong options
于 2012-03-02T03:23:57.313 に答える