libsvm icon indicating copy to clipboard operation
libsvm copied to clipboard

Support for negative examples in one-class added

Open ondracek-lukas opened this issue 7 years ago • 4 comments

  • learning now uses both positive and negaive examples
  • array y should contain +1s for positive examples and -1s for negative
  • based on the "One-class classification" thesis written by door David Martinus Johannes TAX (http://prlab.tudelft.nl/content/one-class-classification-1)

ondracek-lukas avatar Oct 15 '16 15:10 ondracek-lukas

What's the reference of one-class svm with negative samples? BTW the optimization algorithm in libsvm for one-class svm does assume y=1.. So you cannot just change y to have 1 and -1. Lukáš Ondráček writes:

  • learning now uses both positive and negaive examples
  • array y should contain +1s for positive examples and -1s for negative
  • based on the "One-class classification" thesis written by door David Martinus Johannes TAX

You can view, comment on, or merge this pull request online at:

https://github.com/cjlin1/libsvm/pull/74

Commit Summary

  • Support for negative examples in one-class added

File Changes

  • M README (7)
  • M svm.cpp (21)

Patch Links:

  • https://github.com/cjlin1/libsvm/pull/74.patch
  • https://github.com/cjlin1/libsvm/pull/74.diff

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread. *

cjlin1 avatar Nov 08 '16 21:11 cjlin1

What's the reference of one-class svm with negative samples?

It is described in Section 2.2 of the thesis: http://homepage.tudelft.nl/n9d04/thesis.pdf

ondracek-lukas avatar Nov 09 '16 15:11 ondracek-lukas

Your modification doesn't solve their opt problem. See solve_one_class() in svm.cpp:

for(i=0;i<n;i++)
    alpha[i] = 1;
if(n<prob->l)
    alpha[n] = param->nu * prob->l - n;

The init sol is under the assumption of e^Talpha = a positive constant.

Theirs is an extension of SVDD so you should check the SVDD code in libsvmtools

Lukáš Ondráček writes:

What's the reference of one-class svm with negative samples?

It is described in Section 2.2 of the thesis: http://homepage.tudelft.nl/n9d04/thesis.pdf

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread. *

cjlin1 avatar Nov 09 '16 19:11 cjlin1

I am sorry for my poor knowledge of SVMs, can you please explain in more detail what's wrong?

Your modification doesn't solve their opt problem. See solve_one_class() in svm.cpp:

for(i=0;i<n;i++) alpha[i] = 1; if(nl) alpha[n] = param->nu * prob->l - n;

The init sol is under the assumption of e^Talpha = a positive constant.

What does the e vector mean? I haven't found it anywhere.

Why should y be non-negative here, while it is not needed in other occurrences (like in SVR)?

Maybe you have meant y instead of e; in such a case I would be able to answer the previous question, but from what the assumption follows?

Theirs is an extension of SVDD so you should check the SVDD code in libsvmtools

Which part of code do you mean?

In the thesis, description of the model is extended by the vector y of +/- ones, but then it is shown, that the signs can be incorporated in the vector alpha, so that the prediction works the same way as without negative samples. I change the signs of the vector just after calling the Solve method.

ondracek-lukas avatar Nov 14 '16 14:11 ondracek-lukas