I have trained a model and now I want to predict the output for a new query with an svm. First, I got this error "length of 'center' must equal the number of columns of 'x'" which means that there are levels that are in test that are not in training (based on this post https://stackoverflow.com/questions/24224554/error-in-scale-default-length-of-center-must-equal-the-number-of-columns-of).

I tried to use droplevels to the query but then another error occurs "contrasts can be applied only to factors with 2 or more levels". But 2 or more levels cannot be present at the query (dataframe with one row).

So here's my dilemma. How can I overcome this one?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.