Plot SVM model in R -Text classification

2.4k Views Asked by At

I am using SVM model from e1017 in R. I have used SVM for text mining and classification. So my data is dtm(document term matrix obtained from documents corpus). How can I go about plotting my SVM model?

Below is my svm model I used in my code for class prediction

model <- svm(dtm, classvec, kernel="linear")

When I use plot(model, dtm) I get the error

missing formula
1

There are 1 best solutions below

0
On

plot.svm gives missing formula because when you have more than 3 column in your matrix including target variable plot function doesn't know which variables to choose as x and y to plot.To overcome the error you have to explicitly specify x and y in the command.

model <- svm(dtm, classvec, kernel="linear")
plot(model,dtm,x~y)

where x and y are columns you would like to plot from your matrix