当我尝试创建一个参数网格以使用插入符号进行训练时,我得到了各种错误:
> 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
createGrid 的文档说:
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'.
并给出以下正确工作的示例:
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)
有了这个,我做错了什么?
跟进问题:
len
as a argument tocreateGrid
和tuneLength
in the argument for之间有什么联系train
?可以len
和tuneLength
它们一起使用吗?他们是什么关系?
其他有用的线程:
如果有帮助,这里有一个线程描述了如何使用createGrid
in train
: caret
caret ::train: 指定模型生成参数