4

I removed 100 records from the original data set, then rebuilt a SVM model using the following coding.

uk<-read.csv("Riskx.csv", header=TRUE, sep=",")
attach(uk)
library(e1071)
library(kernlab)
index<-1:nrow(uk)
testindex<-sample(index, trunc(length(index)/3))
testset<-uk[testindex,]
trainset<-uk[-testindex,]
model<-ksvm(Risk~, data = trainset, type = "nu-svc")
pred<-predict(model, testset)
table(pred, testset$Risk)
summary(testset$Risk)

NOW, I want to bring in those 100 records I set aside from training/testing the new model and check how well the model can identify and classify those 100 records which it has not seen before. So I did the following coding.

testset<-read.csv(“Validation.csv”, header=TRUE, sep=”,”)
Pred1<-predict(model4, testset)

But R, gives me the following error:

Error in .local(object, …) : test vector does not match model !

Any idea how I could over come this error? The test set used to build the model has 466 records. Therefore I tried duplicating the validation test to 466 as well, but it still gives the same error.

rcs
  • 67,191
  • 22
  • 172
  • 153
Spidey
  • 41
  • 2

0 Answers0