1

I am using OneClassSVM for a binary classification problem. I have a dataset where the target variable is labeled 0 or 1. I don't know if OneClassSVM can be used for binary or multi classification problems, but when I try to predict I get the following: y_true:

[0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 1 1 0 1 0 1 1 1 0 1
 1 1 0 1 0 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0 0 0 1
 0 1 1 1 0 1 0 0 1 0 0 0 0 0 1 0 1 1 0 1 0 1 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1
 0 1 0 0 1 0 0 0 1 0 1 1 1 1 1]

y_pred:

[-1  1  1  1 -1  1  1  1  1  1  1  1  1  1 -1  1  1  1  1  1  1 -1  1  1
  1  1 -1  1  1  1  1  1  1 -1  1  1  1  1 -1  1  1  1  1  1 -1  1  1  1
  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 -1  1  1  1  1  1  1
  1  1  1  1  1  1  1  1  1  1  1  1 

There are many -1 values in the y_pred I assume these are the instances where the model was trying to predict the class 0 but could not ?

Main Question: can OneClassSVM be used for binary classification ?

Perl Del Rey
  • 959
  • 1
  • 11
  • 25

2 Answers2

0

The following link explains well:

https://stats.stackexchange.com/questions/99162/what-is-one-class-svm-and-how-does-it-work

To summarize, if your task is to perform a binary classification simply you should employ sklearn.svm.SVC.

Kidae Kim
  • 499
  • 2
  • 9
-1

Instead of 1 and 0, your output is just 1 and -1.

user3352632
  • 617
  • 6
  • 18