I did a classification with svm
using e1071
. The goal is to predict type
through all other variables in dtm
.
dtm[140:145] %>% str()
'data.frame': 385 obs. of 6 variables:
$ think : num 0 0 0 0 0 0 0 0 0 0 ...
$ actually: num 0 0 0 0 0 0 0 0 0 0 ...
$ comes : num 0 0 0 0 0 0 0 0 0 0 ...
$ able : num 0 0 0 0 0 0 0 0 0 0 ...
$ hours : num 0 0 0 0 0 0 0 0 0 0 ...
$ type : Factor w/ 4 levels "-1","0","1","9": 4 3 3 3 4 1 4 4 4 3 ...
To train/test the model, I used the 10-fold-cross-validation.
model <- svm(type~., dtm, cross = 10, gamma = 0.5, cost = 1)
summary(model)
Call:
svm(formula = type ~ ., data = dtm, cross = 10, gamma = 0.5, cost = 1)
Parameters:
SVM-Type: C-classification
SVM-Kernel: radial
cost: 1
gamma: 0.5
Number of Support Vectors: 385
( 193 134 41 17 )
Number of Classes: 4
Levels:
-1 0 1 9
10-fold cross-validation on training data:
Total Accuracy: 50.12987
Single Accuracies:
52.63158 51.28205 52.63158 43.58974 60.52632 43.58974 57.89474 48.71795
39.47368 51.28205
My question is how can I generate a confusion matrix for the results? Which columns of model
do I have to put in table()
or confusionMatrix()
to get the matrix?