When I try to crate a grid of parameters for training with caret I get various errors: ------------------------------------------------------------> my_grid <- createGrid("rf")Error in if (p <= len) { : argument is of length zero> my_grid <- createGrid("rf", 4)Error in if (p <= len) { : argument is of length zero> my_grid <- createGrid("rf", len=4)Error in if (p <= len) { : argument is of length zero The documentation for createGrid says: ------------------------------------------------------------ This function creates a data frame that contains a grid of complexity parameters specific methods. Usage: createGrid(method, len = 3, data = NULL) Arguments: method: a string specifying which classification model to use. See 'train' for a full list. len: an integer specifying the number of points on the grid for each tuning parameter. data: the training data (only needed in the case where the 'method' is 'cforest', 'earth', 'bagEarth', 'fda', 'bagFDA', 'rpart', 'svmRadial', 'pam', 'lars2', 'rf' or 'pls'). The outcome should be in a column called '.outcome'. and gives the following examples: ------------------------------------------------------------ createGrid("rda", 4) createGrid("lm") createGrid("nnet") ## data needed for SVM with RBF: ## Not run: tmp <- iris names(tmp)[5] <- ".outcome" head(tmp) createGrid("svmRadial", data = tmp, len = 4) ## End(Not run) What I am doing wrong? Also, what is the connection between len above and tuneLength in the argument for train? Thanks, James [[alternative HTML version deleted]]
David Winsemius
2013-Feb-12 19:08 UTC
[R] caret: Errors with createGrid for rf (randomForest)
On Feb 12, 2013, at 10:53 AM, James Jong wrote:> When I try to crate a grid of parameters for training with caret I get > various errors: > ------------------------------------------------------------ >> my_grid <- createGrid("rf") > Error in if (p <= len) { : argument is of length zero > >> my_grid <- createGrid("rf", 4) > Error in if (p <= len) { : argument is of length zero > >> my_grid <- createGrid("rf", len=4) > Error in if (p <= len) { : argument is of length zero > > The documentation for createGrid says: > ------------------------------------------------------------ > This function creates a data frame that contains a grid of > complexity parameters specific methods. > Usage: > createGrid(method, len = 3, data = NULL) > Arguments: > method: a string specifying which classification model to use. See > 'train' for a full list. > len: an integer specifying the number of points on the grid for > each tuning parameter. > data: the training data (only needed in the case where the 'method' > is 'cforest', 'earth', 'bagEarth', 'fda', 'bagFDA', 'rpart', > 'svmRadial', 'pam', 'lars2', 'rf' or 'pls'). The outcome > should be in a column called '.outcome'.Looking at that example, my first guess would be that your call is missing a proper 'data' argument. It says one is needed if the method is 'rf'. -- david.> > > and gives the following examples: > ------------------------------------------------------------ > createGrid("rda", 4) > createGrid("lm") > createGrid("nnet") > > ## data needed for SVM with RBF: > ## Not run: > > tmp <- iris > names(tmp)[5] <- ".outcome" > head(tmp) > createGrid("svmRadial", data = tmp, len = 4) > ## End(Not run) > > > What I am doing wrong? > > Also, what is the connection between len above and tuneLength in the > argument for train? > > Thanks, > > James > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.David Winsemius Alameda, CA, USA
Maybe Matching Threads
- caret train and trainControl
- CARET: Any way to access other tuning parameters?
- caret package, how can I deal with RFE+SVM wrong message?
- CARET and NNET fail to train a model when the input is high dimensional
- Inconsistent results between caret+kernlab versions