e1071 SVM: Cross-validation error confusion matrix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

e1071 SVM: Cross-validation error confusion matrix

ChristianR
Hi,

I ran two svm models in R e1071 package: the first without cross-validation and the second with 10-fold cross-validation.

I used the following syntax:

#Model 1: Without cross-validation:
> svm.model <- svm(Response ~ ., data=data.df, type="C-classification", kernel="linear", cost=1)
> predict <- fitted(svm.model)
> cm <- table(predict, data.df$Response)
> cm

#Model2: With 10-fold cross-validation:
> svm.model2 <- svm(Response ~ ., data=data.df, type="C-classification", kernel="linear", cost=1, cross=10)
> predict2 <- fitted(svm.model2)
> cm2 <- table(predict2, data.df$Response)
> cm2

However, when I compare cm and cm2, I notice that the confusion matrices are identical although the accuracy of each model is diffent. What am I doing wrong?
 
Thanks for you help,

Chris
Reply | Threaded
Open this post in threaded view
|

Re: e1071 SVM: Cross-validation error confusion matrix

signal
Did you ever receive a response to this? I did not see one public.

I would think that if your dataset was of a large enough size, that 10-fold validation would show an improvement over N:N.

Also, any ideas if there is any difference really in using fitted() vs. predict() in your second step? I am pretty sure they do the same thing.  

Brian
Reply | Threaded
Open this post in threaded view
|

Re: e1071 SVM: Cross-validation error confusion matrix

signal
responding to my own question, I see in ?svm man it states fitted() and predict() can do the same thing:

# test with train data
pred <- predict(model, x)
# (same as:)
pred <- fitted(model)



On Nov 21, 2012, at 1:08 AM, signal <[hidden email]> wrote:

> Did you ever receive a response to this? I did not see one public.
>
> I would think that if your dataset was of a large enough size, that 10-fold
> validation would show an improvement over N:N.
>
> Also, any ideas if there is any difference really in using fitted() vs.
> predict() in your second step? I am pretty sure they do the same thing.  
>
> Brian
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/e1071-SVM-Cross-validation-error-confusion-matrix-tp4437047p4650252.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.