I am using the svm function in the e1071 package of R. Using svm function I could get an accuracy of 74% for my data, but when I try to use the predict function for a test dataset, it returns all of the data in one of the two categories and shows 0 in the other. This is what the code looks like
test <- read.table(file.choose(), header=T)
pred <- predict(modelb, test)
summary(pred)
0 1
101 0
One of the possibilities is that your training dataset is imbalanced.
Let's say that you have 100 of samples in class 0 and 1 sample in class 1. In some cases, the best solution is given by putting every new example in class 0.
A few solutions include :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.