0
votes

I am trying to code a SVM for classification using a training data-set that contains only one type of class. So, i want to predict if some data is different or not from my data-set.

I used the same data-set as the training for predicting, but unfortunately, the SVM is not predicting well.

library(e1071)

# Data set
high  <- c(10,5,14,12,20)
temp  <- c(12,15,20,15,9)
x <- cbind(high,temp)

# Create SVM
model <- svm(x,y=NULL,type='one-classification',kernel='linear')

# Predict training data-set
pred <- predict(model,x)
pred

It returns: TRUE TRUE FALSE FALSE TRUE

It should be TRUE for all of them.

2
possible duplicate: stackoverflow.com/questions/27375517/…. But really this question is more about modeling than coding. You probably should be asking at Cross Validated or Data Science.MrFlick
Thanks, but this one is using a structured data and i don't know the structure of "iris". I have done a SVM in python and its working pretty well, but now i have to do using R.Vitor
I used the "possible duplicate" and it has the same error as mine. The svm is not predicting correctly the training data-set. When i use the same data as i used in the training the function predict returns 50% of TRUE and 50% of FALSE.Vitor

2 Answers

0
votes

I am working on a similar problem. In reading the vignette's that the e1071 authors have at CRAN I believe that by definition the SVM is going to draw a hyperplane that separates it into 2 classes. In other words, that 3rd item is the most likely to be an outlier. SVM will always define at least one outlier.

0
votes

I'm not sure traditional supervised learning techniques, such as SVMs, are well suited to training data where you only have 1 class. There's nothing in the data to inform the model how to differentiate between class A and class B.

I think the best you can do with your 1-class training data is to learn a probability density/mass function from the data, and then find how likely a new instance is under the learned probability density. For some more info see the wikipedia article on one-class classification.