[英]Predict.svm function in e1071 package of R
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. 我在R的e1071软件包中使用了svm函数。使用svm函数,我的数据可以达到74%的精度,但是当我尝试对测试数据集使用预测函数时,它会将所有数据返回一个两个类别中的一个,在另一个类别中显示0。 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. 假设您有100个类别0的样本和1个类别1的样本。在某些情况下,最好的解决方案是将每个新的示例放入类别0。
A few solutions include : 一些解决方案包括:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.