Error In predict function after using SVM for classification

p<- predict(mymodel, train)
table(predict(p), train$Air.Quality)

Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "factor"

Your p is the result of calling predict. Yet you pass it as a param to a call of predict? Just leave predict() out of your table() call

Do you mean to write it as this

table(p, train$Air.Quality)

This forum won't allow me to post without a minimum of 20 characters ...

Yes

thanks a lot for your help, the error is gone by following your tip.

but i have another question , after i wrote this code i got another error, i know i got this error because i have missing values in my data. but the point is i want to evaluate the performance of the classifier with and without NAs. so any help please to run the confusion matrix while having NAs.

p<- predict(mymodel1, train)
table(p, train$Air.Quality)
Error in table(p, train$Air.Quality) :
all arguments must have the same length

length(train$Air.Quality)
[1] 4020
length(p)
[1] 1998

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.