【发布时间】:2017-04-19 15:17:07
【问题描述】:
我有以下数据
scorer<-function(points){
points["scores"] <- as.vector((points$X-5)^2+(points$Y-5)^2-9)
points["class"]<-(as.vector( points$scores<0 ))
points
}
dt<-scorer(data.frame(X=c(0,1,5,20,5,3,9,3,5,5),Y=c(0,9,9,0,-18,3,4,5,7,4)))
然后我尝试使用 SVM 预测最后一列(类)
library(e1071)
model <- svm(class ~ . , dt)
predictedClass <- predict(model, dt)
但它抱怨:
Error in svm.default(x, y, scale = scale, ..., na.action = na.action) :
Need numeric dependent variable for regression.
【问题讨论】:
-
尝试指定您希望分类而不是回归:
model <- svm(class ~ . , dt, type = "C").
标签: r