I have a dataframe I want to make predictions on from an SVM, but the dataframe doesn\'t have all of the levels that the original training dataframe did. Is there an easy way ar
Just be sure to specify the levels in df2
df2
library(e1071) df = data.frame(y = c(rep(1:3, each = 3)), x = rep(c("A", "B", "C"), each = 3)) m1 = svm(y ~ x, df) df2 = data.frame(x = factor("B",levels = c("A","B","C"))) predict(m1, df2)