【发布时间】:2015-03-23 15:35:14
【问题描述】:
得到以下错误:
Error in xy.coords(x, y, xlabel, ylabel, log) : x' and 'y' lengths differ
当我尝试运行以下代码时。我知道这与我的 x 和 y 的长度有关。:
install.packages("e1071")
library("e1071")
mydata <- read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv", sep=";", header=TRUE);
#Go on split the data into a training and test set.
index <- 1:nrow(mydata)
testindex <- sample(index, trunc(length(index)/3))
testset( <-mydata[testindex,]
trainset <- mydata[-testindex,]
svm.model <- svm(formula = as.factor(quality) ~ residual.sugar, data = trainset, kernel = linear, method = "class")
svm.pred <- predict(svm.model, trainset, type = "class")
table(pred = svm.pred, true = trainset[,10)
plot(svm.pred, testset)
我检查了长度,但我不明白为什么我的测试集是 12。
谢谢
【问题讨论】:
-
testset( <-mydata[testindex,]testset后面有个括号 -
大声笑我把它放进去的错误,但这与原来的问题无关。错误仍然存在。