【发布时间】:2017-04-06 13:40:58
【问题描述】:
我正在尝试运行不需要参数的插入符号方法,例如 lda,下面的示例使用需要 2 个参数(大小和 k)的“lvq”
set.seed(7)
# load the library
library(caret)
# load the dataset
data(iris)
# prepare training scheme
control <- trainControl(method="repeatedcv", number=10, repeats=3)
# design the parameter tuning grid
grid <- expand.grid(size=c(5,10,20,50), k=c(1,2,3,4,5))
# train the model
model <- train(Species~., data=iris, method="lvq", trControl=control, tuneGrid=grid)
# summarize the model
print(model)
plot(model)
我试图解决分配 tuneGrid=NULL
set.seed(7)
# load the library
library(caret)
# load the dataset
data(iris)
# prepare training scheme
control <- trainControl(method="repeatedcv", number=10, repeats=3)
# design the parameter tuning grid
grid <- expand.grid(size=c(5,10,20,50), k=c(1,2,3,4,5))
# train the model
model <- train(Species~., data=iris, method="lda", trControl=control, tuneGrid=NULL)
# summarize the model
print(model)
plot(model)
但我得到了错误
There are no tuning parameters for this model
【问题讨论】:
-
您正在打印
lda,但您将结果分配给lda2。似乎这只是一个错字。但在寻求帮助时,请确保包含包含示例数据的reproducible example。我们无法运行此代码来查看问题所在,因为我们的计算机上不存在该输入文件。