Error in predict.svm: test data does not match model

非 Y 不嫁゛ 提交于 2019-12-01 09:40:13

This happens when the columns in test and train data aren't same. Try str(training.data) & str(testing.data) they should have the same variables except for the one that needs to be predicted. Include only those factors you want to use for prediction in the svm training model.

For eg:

fit <- svm(SEGMENT ~ ., data = training.data[,1:6], cost = 1, kernel = 'linear', 
+ probability = T, type = 'C-classification')     


x <- predict(fit, testing.data[,1:5], decision.values = T, probability = T)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!