[R] ipred: possible to use svm in errorest?

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Jun 22 10:44:11 CEST 2011



On 21.06.2011 13:56, Daniel Stahl wrote:
> Dear all,
>
>
> is it possible to run the support vector machine command "svm" from the
> package e1071 within the errorest function from the library ipred?
> It works fine for lda and rda but I get an error message (see below)
>
> Thank you for your help.
> Best wsihes, Daneil
>
>
> # Classification
>
> data(iris)
>
> # force predict to return class labels only
> mypredict.lda<- function(object, newdata)
> predict(object, newdata = newdata)$class
>
>> # 10-fold cv of LDA for Iris data
>> errorest(Species ~ ., data=iris, model=svm, estimator = "cv", predict=
>> mypredict.lda)
> Error in predict(object, newdata = newdata)$class :
>      $ operator is invalid for atomic vectors


The point of specifying a predict function is to tell errorest how to 
get the classes from predict(). Since predict.svm already returns the 
classes you can omit it:
errorest(Species ~ ., data=iris, model=svm, estimator = "cv")

Uwe Ligges


>
>
> --
>
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list