A Data Science Central Community
i am using R to fit svms using the e1071 package. Everything seems fine when i train the model, and even when validating with a different data-set. the training data-set has 1500 records and 17 variables. When i attempt to generate a classification matrix i obtain the following error:
“Error in table(pred = prediction, true = observed) : all arguments must have the same length”
below is my R code from model fitting up to when i get the error. I have checked the length of the length(sum.pred)=1500 while the length of the length(CARDTRAIN)=17. please assist in helping me figure out the above error.
svm.model <- svm(FRAUD_IND ~ ., data = CARDTRAIN2,family=binomial,prob.model=TRUE)
svm.pred <- predict(svm.model, CARDTRAIN2,decision.values=TRUE,probability=TRUE)
You get an error because you give a complete data.frame as a second argument to table instead of labels column only.
Assuming that your label column is "FRAUD_IND" it should go like this:
that also doesnt work