Suppressing output in libsvm (python)

I am using libsvm (svmutils) from python for the classification task. The classifier is accurate. However, I get the output as follows:

* 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) 

Is there any way to suppress this dialogue? The classifier works fine, I'm just curious. Also, what does "Accuracy" mean? And why is this 0% in my case? (Data does not overlap in 80 sizes. Only 4 classes. I also normalized it correctly.)

+4
source share
3 answers

Use the -q option parameter

 import svmutil param = svmutil.svm_parameter('-q') ... 

or

 import svmutil x = [[0.2, 0.1], [0.7, 0.6]] y = [0, 1] svmutil.svm_train(y, x, '-q') 
+4
source

This may work:

 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 

In addition, in classification tasks, accuracy is part (percentage) of correctly predicted elements from your test / cross-validation established using a trained model.

+1
source

To suppress the output of training and forecasting, you need to combine the solutions provided by has2k1 (to suppress the learning) and vonPetrushev (to suppress the output of the forecast).

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 ) 

Due to 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 
+1
source

Source: https://habr.com/ru/post/1383521/


All Articles