LIBSVM Learner One class SVM

I have some questions about the LIBSVM Learner:
Currently I am trying to train a one class model with the LIBSVM learner. My training data contains numeric features with only positive classes, so there is only one class. I cannot leave the target column empty in the learner settings, so I appended a column with a constant value of 1 and defined it as the target column. Then I am applying the predictor with the input of a testset without class labelings. My question now is, how is the output of the predictor supposed to be? Every row got the class predicition “1”, I expected something like that only some of the rows in the test dataset are labeled as “1”, not all.
Am I doing something wrong or should the input data be different?

Thanks in advance!


well if your model does only have one class it will always predict that one class as you trained it to to exactly this. What you basically did is tell your model to learn that whatever the input is it should predict 1. So it does not learn anything ( Mathematically speaking its f(inputs) = 1) as there is no dependency between inputs and class. You either need some data with different labels, so your model can distinguish between classes, or you need other techniques for training.

I guess what you might be looking for are techniques for outlier detection which can (very generally speaking) recognize if your input is far away from the training data.


Hello Jennifer,

thanks for your quick answer!
I get your point, but if my input contains two classes, for example 1 and 0, then what is the point of the option in the LIBSVM learner node “one class SVM”?
Also I tried to use the node LIBSVM 3.7 from weka with the option One class SVM, but it gives me an error if i have two classes as input, saying it “cannot handle binary class”.


One-class classification is actually really a bit different (see Wiki) from typical classification, where you try to learn a model which can distinguish between two or more classes. In one class classification you try to learn a model which can distinguish objects from one class from all other objects. Often an assumption is that the objects of one class you want to distinguish from the other objects not of this class share some common properties/features, while all objects which don’t belong to your class can’t really be modeled.

Hello @christian.dietz,
yes, that is exactly why I am trying to build an one class model.
I am training the one-class SVM with data that contains one class only. But my problem is as I said, it is predicting everything in the same given class. And I wonder how the output of the predictor node supposed to look like? And if its right that I only train with one class data?


Hello @jngo could you solve the problem? I am stuck in the same thing. Can you please help me? I am using Weka in Java for it.