Giter Site home page Giter Site logo

Comments (3)

cjlin1 avatar cjlin1 commented on June 2, 2024

This isn't a bug. Please see the following libsvm faq.

Q: Why using svm-predict -b 0 and -b 1 gives different accuracy values?

Let's just consider two-class classification here. After probability information is obtained in training, we do not have

prob > = 0.5 if and only if decision value >= 0.

So predictions may be different with -b 0 and 1.

Nick writes:

I am using libsvm 3.20. I have a dataset which causes svm_predict() and
svm_predict_probability() to give different results. In particular, svm_predict()
classifies everything to one class, which is definitely wrong for this dataset.

You can trigger it with the command line tools as follows

wget https://github.com/kousu/statasvm/raw/master/bugs/libsvm_classification/classification_bug.svmlight

svm-train -b 1 classification_bug.svmlight FIT >/dev/null &&

svm_predict(), incorrect

svm-predict -b 0 classification_bug.svmlight FIT P
cat P

svm_predict_probability(), correct (or at least, reasonable)

svm-predict -b 1 classification_bug.svmlight FIT P
cat P

Tabulating the results, I see

svm_predict(), incorrect

Model supports probability estimates, but disabled in prediction.
Accuracy = 53.5294% (91/170) (classification)
170 1

svm_predict_probability()

Accuracy = 84.7059% (144/170) (classification)
labels 0 1 2 3
61 0
100 1
9 2

Reference dataset and full test cases are at
https://github.com/kousu/statasvm/tree/master/bugs/libsvm_classification. This
showed up when run from my Stata wrapper in that repo, but it is also in sklearn
and in your command line tools.

I hit the svm_predict() bug a week ago, but I was even more surprised to see that
despite it, you can still good answers out of libsvm by tweaking parameters. Given
the huge number of machine learning projects that are dependent on your code,
there must be a lot of subtlely incorrect predictions that no one is catching. Do
you have any idea what would cause this?


Reply to this email directly or view it on GitHub.*

from libsvm.

kousu avatar kousu commented on June 2, 2024

I missed that in the FAQ. It is short and hard to interpret. Perhaps incorporating some of the points made by sklearn would make this corner-case clearer.

from libsvm.

StevenLOL avatar StevenLOL commented on June 2, 2024

Agreed, sklearn has the best documentation.

from libsvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.