enquiry about errorest with model-knn
2
0
Entering edit mode
Liu, Xin ▴ 130
@liu-xin-909
Last seen 10.2 years ago
Dear all, Can somebody give me a clue why I always get the following error? errorest(Species ~ ., data = iris, model = knn, estimator = "cv")$err Error in model(formula, data = folddata, ...) : unused argument(s) (data ...) Xin LIU This e-mail is from ArraDx Ltd The e-mail and any files transmitted with it are confidentia...{{dropped}}
• 1.9k views
ADD COMMENT
0
Entering edit mode
@holger-schwender-344
Last seen 10.2 years ago
Hi Xin, first of all you must replace knn by ipredknn. Then you have to write your own predict function (see the help of errorest in the ipred package). Something like > mypredict.knn <- function(object, newdata) + predict(object, newdata = newdata,type="class") should work. Then your knn analysis can be done by > errorest(Species ~ ., data = iris, model = ipredknn, estimator = "cv", + predict=mypredict.knn) By the way, this is actually a question for the R help and not for the BioC help. Best, Holger > Dear all, > > Can somebody give me a clue why I always get the following error? > > errorest(Species ~ ., data = iris, model = knn, estimator = "cv")$err > > Error in model(formula, data = folddata, ...) : > unused argument(s) (data ...) > > Xin LIU > > This e-mail is from ArraDx Ltd > > The e-mail and any files transmitted with it are confidentia...{{dropped}} > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > -- +++ Sparen Sie mit GMX DSL +++ http://www.gmx.net/de/go/dsl AKTION für Wechsler: DSL-Tarife ab 3,99 EUR/Monat + Startguthaben
ADD COMMENT
0
Entering edit mode
Liaw, Andy ▴ 360
@liaw-andy-125
Last seen 10.2 years ago
The function knn() has no formula interface nor a predict() function (for good reasons), which errorest() requires, as said in the `Details' section of ?errorest: Any model can be specified as long as it is a function with arguments model(formula, data, subset, na.action, ...). If a method predict.model(object, newdata, ...) is available, predict does not need to be specified. However, predict has to return predicted values in the same order and of the same length corresponding to the response. See the examples below. Andy > From: Liu, Xin > > Dear all, > > Can somebody give me a clue why I always get the following error? > > errorest(Species ~ ., data = iris, model = knn, estimator = "cv")$err > > Error in model(formula, data = folddata, ...) : > unused argument(s) (data ...) > > Xin LIU > > This e-mail is from ArraDx Ltd > > The e-mail and any files transmitted with it are > confidentia...{{dropped}} > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > >
ADD COMMENT

Login before adding your answer.

Traffic: 521 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6