0
$\begingroup$

I am doing SVM on R, and when I do:

fit2 = svm(satisfied~PC1 + PC2 + PC3 + PC4, data=data.frame(train.incl.score.x.y.st), kernel="radial", cost=5, gamma=500)

pred2=predict(fit2, data.frame(val.incl.score[,1:4]),  probabiltiy=FALSE)

table(pred2, data.frame(val.incl.score.x.y.st)$satisfied)

>> pred2.                  0 1
  -8.37175892132423        1 0
  -7.98589263979825        1 0
  -6.74777840420131        1 0
  -6.70935986153772        1 0
  -6.46316720580385        1 0
  -6.04268844390794        1 0

 <list goes on...>

What I want is I want the column pred2 in the output above to display the predicted class type instead of the numerical value that the SVM model assigns to each observation. How can I get the predicted class type for each validation observation, and make confusion matrix accordingly?

Thank you,

$\endgroup$
0
$\begingroup$

I've seen this before, and it was because the response variable was numeric, rather than factor. As a result, the SVM was doing regression, rather than classification.

Have you checked to see if 'satisfied' is a factor variable? I think that should resolve it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.