libsvm:C ++与MATLAB:具有不同的精度是什么? [英] libsvm : C++ vs. MATLAB : What's With The Different Accuracies?

查看:103
本文介绍了libsvm:C ++与MATLAB:具有不同的精度是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个带有5个标签的多类数据集,一个用于训练,另一个用于交叉验证.这些数据集存储为.csv文件,因此在本实验中它们充当控件.

I have two multi-class data sets with 5 labels, one for training, and the other for cross validation. These data sets are stored as .csv files, so they act as a control in this experiment.

我有一个用于libsvm的C ++包装器,以及一个用于libsvm的MATLAB函数.

I have a C++ wrapper for libsvm, and the MATLAB functions for libsvm.

对于C ++和MATLAB: 使用带有RBF内核的C型SVM,我遍历了2个C和Gamma值列表.对于每种参数组合,我在训练数据集上进行训练,然后预测交叉验证数据集.我将预测的准确性存储在2D映射中,该映射与产生准确性的C和Gamma值相关.

For both C++ and MATLAB: Using a C-type SVM with an RBF kernel, I iterate over 2 lists of C and Gamma values. For each parameter combination, I train on the training data set and then predict the cross validation data set. I store the accuracy of the prediction in a 2D map which correlates to the C and Gamma value which yielded the accuracy.

我已经多次创建了不同的训练和交叉验证数据集.每次,C ++和MATLAB的精度都是不同的.有时候很多!通常,MATLAB具有更高的精度,但有时C ++实现会更好.

I've recreated different training and cross validation data sets many, many times. Each time, the C++ and MATLAB accuracies are different; sometimes by a lot! Mostly MATLAB produces higher accuracies, but sometimes the C++ implementation is better.

这些差异可能是什么原因造成的?我尝试使用的C/Gamma值与其余SVM参数(默认值)相同.

What could be accounting for these differences? The C/Gamma values I'm trying are the same, as are the remaining SVM parameters (default).

推荐答案

应该没有显着差异,因为C和Matlab代码都使用相同 svm.c文件.那是什么原因呢?

There should be no significant differences as both C and Matlab codes use the same svm.c file. So what can be the reason?

  • 您的代码中的实现错误,很遗憾,这是最有可能的错误
  • 使用的包装器有一些错误和/或使用其他版本的libsvm,然后使用您的matlab代码(libsvm用纯C语言编写,并带有python,Matlab和Java包装器,因此您的C ++包装器是非官方的")或包装器假定一些其他默认值,在C/Matlab/Python/Java实现中不是默认值
  • 您以某种随机形式执行交叉验证(对数据进行混排然后折叠,这是完全正确和合理的,但是在两次不同的运行中会导致不同的结果)
  • 在其中一个(或两个)代码中从.csv加载数据期间执行了一些舍入/转换操作,这导致不一致(实际上不太可能发生,但仍然可能)

这篇关于libsvm:C ++与MATLAB:具有不同的精度是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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