注册 | 登录

Matlab libsvm svmpredict accuracy verbose





下载 libsvm库下载: 数据集下载: 配置 设置path:File->

up vote 0 down vote favorite I have a question of an annoying fact. I'm using libsvm with matlab and I'am able to predict using: predicted_label = svmpredict(Ylabel, Xlabel, model);

but it happen that every time I make a predictions appears this: Accuracy = X% (y/n) (classification)

Which I find annoying because I am repeating this procedure a lot of times and also makes it slow because its displaying in screen. I think what I want is to avoid that svmpredict being verbose. Can anyone help me with this? Thanks in advance. -Jessica matlab libsvm verbose
  this question asked Aug 21 '13 at 7:07 jessica 132 3 17

 |  3 Answers

up vote 2 down vote ---Accepted---Accepted---Accepted---

If you are using matlab, just find the line of code that is displaying this information (usually using 'disp', 'sprintf', or 'fprintf') and comment it out using the commenting operator %. example: disp(['Accuracy= ' num2str(x)]);

change it to: % disp(['Accuracy= ' num2str(x)]);

If you are using the main libsvm library then you need to modify it before making. 1- Open the file 'svmpredict.c' 2- find this line of code: info("Accuracy = %g%% (%d/%d) (classification)\n",


3- just comment it out using // operator 4- save and close the file 5- make the project
  this answer edited Aug 21 '13 at 8:10 answered Aug 21 '13 at 7:43 NKN 5,368 5 25 43 In addition to these suggestions, you may take a look at… –  Marc Claesen Aug 21 '13 at 8:46

 |  up vote 7 down vote I found a much better approach than editing the source code of the c library was to use matlabs evalc which places any output to the first output argument. [~ predicted_label] = evalc('svmpredict(Ylabel, Xlabel, model)');

Because the string to be evaluated is fixed should be no performance

推荐:在linux 配置matlab的 libsvm

libsvm作为一个svm的拓展,可以处理多分类问题。 参考: libsvm 库下载位置: 根据libsvm-3.20/matlab 下的readme 1.

  this answer answered Aug 21 '13 at 10:06 Philliproso 641 1 4 14 I found this the easiest and most straight-forward solution –  user2208604 Mar 25 '15 at 21:06 Unfortunately this seems to be the only way to achieve this (without recompiling the source). –  zelanix May 22 '15 at 16:08

 |  up vote 6 down vote svmpredict(Ylabel, Xlabel, model, '-q');

From the manual: Usage: [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options')

[predicted_label] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options')


model: SVM model structure from svmtrain.


-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); one-class SVM not supported yet

-q : quiet mode (no outputs)

  this answer answered Nov 18 '13 at 21:49 isakkarlsson 912 8 12 This is actually the best way to do it, doesn't involve recompiling things.. –  powder Apr 16 '14 at 12:18 1 Unfortunately quiet mode still has some outputs. Not no outputs. If you are doing grid based hyper-parameter searches your command line can still get flooded. –  Philliproso Mar 26 '15 at 8:09 Not really an answer to the question because this still outputs the Accuracy = ... message that the OP was trying to hide. –  zelanix May 22 '15 at 16:07



趁着所里的网好,我赶紧写下这么一篇bug调试,是关于matlab与 libsvm-mat-2.89-3[FarutoUltimate3.0Mcode] 的(一下简称libsvm)。 闲话不多说了,首先介绍一下博

up vote 0 down vote favorite I have a question of an annoying fact. I'm using libsvm with matlab and I'am able to predict using: predicted_label = svmpredict(Ylabel, Xlabel, model)








您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱