[英]Matlab libsvm svmpredict accuracy verbose
I have a question of an annoying fact. 我有一个令人讨厌的事实的问题。 I'm using libsvm with matlab and I'am able to predict using:
我将libsvm与matlab结合使用,并且能够预测使用:
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. 我想我想要的是避免svmpredict太冗长。
Can anyone help me with this? 谁能帮我这个? Thanks in advance.
提前致谢。
-Jessica -杰西卡
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. 我发现比编辑c库的源代码更好的方法是使用matlabs evalc ,它将所有输出放置到第一个输出参数。
[~ predicted_label] = evalc('svmpredict(Ylabel, Xlabel, model)');
Because the string to be evaluated is fixed should be no performance decrease. 因为要评估的字符串是固定的,所以不会降低性能。
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')
Parameters:
model: SVM model structure from svmtrain.
libsvm_options:
-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); one-class SVM not supported yet
-q : quiet mode (no outputs)
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 % . 如果您使用的是matlab,只需找到显示此信息的代码行(通常使用'disp' , 'sprintf'或'fprintf' ),然后使用注释运算符%对其进行注释。
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. 如果您使用的是主libsvm库,则需要在制作之前对其进行修改。 1- Open the file 'svmpredict.c'
1-打开文件'svmpredict.c'
2- find this line of code: 2-找到以下代码行:
info("Accuracy = %g%% (%d/%d) (classification)\n",
(double)correct/total*100,correct,total);
3- just comment it out using // operator 3-只需使用//运算符将其注释掉
4- save and close the file 4-保存并关闭文件
5- make the project 5-做项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.