[scikit-learn] Decoding Differences Between SKL SVM and Matlab Libsvm Even When Parameters the Same

Taylor, Johnmark johnmarktaylor at g.harvard.edu
Wed Jun 22 14:50:25 EDT 2016


Many thanks for the responses thus far!


*Did you fix the random seeds across implementations as well?
Differencesin seeds or generators might explain this.*

The implementation of libsvm used by Matlab always has a seed of 1. I tried
setting the seed for SKL SVM to 1 (and 0, 2, 3, and 4) as well, and the
results were still different.




*Did you try using the Python API to libsvm directly instead of through
SKL?I'm guessing you have it on your computer since you have the Matlab
API.That would at least let you test whether it's the fake data or whether
it'sSKL.*

I'll give that a shot next, thanks!






*Also are you loading the fake data from a .mat file into Python (e.g.
withthe SciPy 'loadmat' function) or are you generating it from a script?
Maybesome weird floating point error between Python and Matlab is giving
you thedifferent results? This could happen if you generate the data with a
scriptwritten in both Python and Matlab, for example... along the same
lines asthe random seed generator giving different results*

I'm generating the fake data with a Python script and saving it to a .txt
file, which is then loaded in by Python and Matlab in their respective
scripts. To make sure there's no truncation error going on when they load
in this .txt file to get the fake data, I applied the floor function to
both sets of vectors (to make them ints) in both the Python and Matlab
scripts, and they still give different results. So I don't think it's a
data issue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20160622/c133a9ac/attachment.html>


More information about the scikit-learn mailing list