A Data Science Central Community
Hi Everyone,
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)
table(pred=svm.pred, true=CARDTRAIN2)#error
Tags: Error:all, R, SVM, arguments, have, length, must, same, the
Hi Mark,
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:
table(pred=svm.pred, true=CARDTRAIN2$FRAUD_IND)
Darek
that also doesnt work
© 2021 TechTarget, Inc. Powered by
Badges | Report an Issue | Privacy Policy | Terms of Service
Most Popular Content on DSC
To not miss this type of content in the future, subscribe to our newsletter.
Other popular resources
Archives: 2008-2014 | 2015-2016 | 2017-2019 | Book 1 | Book 2 | More
Most popular articles