简体   繁体   English

使用OpenCV获取多类分类中的SVM分类分数

[英]Get SVM classification score in multiclass classification with OpenCV

I'm working on a project where I'm doing multiclass classification with SVM in OpenCV. 我正在开发一个项目,我在OpenCV中使用SVM进行多类分类。

My goal is to get the confidence score of the classification as well as the predicted class. 我的目标是获得分类的置信度分数以及预测的等级。 How can I do that? 我怎样才能做到这一点? Right now I'm doing something like 现在我正在做类似的事情

float result = mysvm.predict(sample);

Having a fairly high amount of classes I prefer to avoid doing a lot of one-vs-all classifications and then calculate the scores. 拥有相当多的课程,我宁愿避免做很多一对一的分类,然后计算分数。

Since OpenCV SVM is implemented using LibSVM, I'm quite sure that there is a way to do this, but looking at http://docs.opencv.org/modules/ml/doc/support_vector_machines.html doesn't really help. 由于OpenCV SVM是使用LibSVM实现的,我很确定有一种方法可以做到这一点,但是查看http://docs.opencv.org/modules/ml/doc/support_vector_machines.html并没有真正帮助。

Thanks for any input provided. 感谢您提供的任何输入。

In opencv/include/opencv2/ml/ml.hpp , there is a struct called CvSVMDecisionFunc .. It has been used in line 546 as a Protected Variable , opencv / include / opencv2 / ml / ml.hpp中 ,有一个名为CvSVMDecisionFunc的结构。它已在第546行用作保护变量

CvSVMDecisionFunc* decision_func;

What you need to do is to cut that line and paste it as Public and then do a complete rebuild of OpenCV.. This variable, decision_func contains all the data for specific support vectors (ie, the alpha and rho values).. 您需要做的是剪切该行并将其粘贴为Public ,然后完成OpenCV的重建。此变量, decision_func包含特定支持向量的所有数据(即alpha和rho值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM