0
votes

i trying do create a plot for my model create using SVM in e1071 package.

my code to build the model, predict and build confusion matrix is

ptm <- proc.time()
svm.classifier = svm(x = train.set.list[[0.999]][["0_0.1"]],
                  y =  train.factor.list[[0.999]][["0_0.1"]],
                 kernel ="linear")

pred = predict(svm.classifier, test.set.list[[0.999]][["0_0.1"]], decision.values = TRUE)
time[["svm"]] = proc.time() - ptm

confmatrix = confusionMatrix(pred,test.factor.list[[0.999]][["0_0.1"]])
confmatrix

train.set.list and test.set.list contains the test and train set for several conditions. train and set factor has the true label for each set. Train.set and test.set are both documenttermmatrix.

Then i tried to see a plot of my data, i tried with

plot(svm.classifier, train.set.list[[0.999]][["0_0.1"]])

but i got the message:
"Error in plot.svm(svm.classifier, train.set.list[[0.999]][["0_0.1"]]) : missing formula."

what i'm doing wrong? confusion matrix seems good to me even not using formula parameter in svm function

1

1 Answers

-1
votes

Without given code to run, it's hard to say exactly what the problem is. My guess, given

?plot.svm

which says

formula         formula selecting the visualized two dimensions. Only needed if more than two input variables are used.

is that your data has more than two predictors. You should specify in your plot function:

plot(svm.classifier, train.set.list[[0.999]][["0_0.1"]], predictor1 ~ predictor2)