使用OpenCV在多类分类中获得SVM分类分数 [英] Get SVM classification score in multiclass classification with OpenCV

查看:1906
本文介绍了使用OpenCV在多类分类中获得SVM分类分数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,我在OpenCV中使用SVM进行多类分类。

I'm working on a project where I'm doing multiclass classification with SVM in OpenCV.

我的目标是获得分类的置信度分数作为预测类。
我如何做到这一点?现在我正在做类似

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.

由于OpenCV SVM是使用LibSVM实现的,我相信有一种方法可以做到这一点,但看着 http://docs.opencv.org/modules/ml/doc/support_vector_machines.html

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.

感谢您提供任何输入。

推荐答案

p>在 opencv / include / opencv2 / ml / ml.hpp 中,有一个名为 CvSVMDecisionFunc 的结构。 >作为受保护的变量,

In opencv/include/opencv2/ml/ml.hpp, there is a struct called CvSVMDecisionFunc.. It has been used in line 546 as a Protected Variable,

CvSVMDecisionFunc* decision_func;

您需要做的是剪切该行并将其粘贴为公共然后做一个完整的OpenCV重建。这个变量 decision_func 包含特定支持向量的所有数据(即alpha和rho值)。

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

这篇关于使用OpenCV在多类分类中获得SVM分类分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆