R 运行不带参数的插入符号方法

R 运行不带参数的插入符号方法,r,r-caret,R,R Caret,我正在尝试运行一个不需要参数的插入符号方法,例如lda,下面的示例使用“lvq”,它需要2个参数(size和k) 我将回答我自己的问题,我认为只要删除tuneGrid=NULL就可以了 set.seed(7) # load the library library(caret) # load the dataset data(iris) # prepare training scheme control <- trainControl(method="repeatedcv", number=

我正在尝试运行一个不需要参数的插入符号方法,例如lda,下面的示例使用“lvq”,它需要2个参数(size和k)


我将回答我自己的问题,我认为只要删除
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)
# summarize the model
print(model)
set.seed(7)
#加载库
图书馆(插入符号)
#加载数据集
数据(iris)
#制定培训计划

控制我将回答我自己的问题,我认为只要删除
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)
# summarize the model
print(model)
set.seed(7)
#加载库
图书馆(插入符号)
#加载数据集
数据(iris)
#制定培训计划

control插入符号包含许多类似LDA的内容:

method=“lda”不涉及任何调谐参数。 method=“lda2”允许调整dimen(鉴别向量的数量)


如果要调整参数(并且必须是唯一的鉴别向量数),必须使用“lda2”。“lda”不允许调谐,因此要运行它,必须删除tuneGrid。删除tuneGrid只需关闭交叉验证。

插入符号包含许多类似于以下内容的LDA:

method=“lda”不涉及任何调谐参数。 method=“lda2”允许调整dimen(鉴别向量的数量)


如果要调整参数(并且必须是唯一的鉴别向量数),必须使用“lda2”。“lda”不允许调谐,因此要运行它,必须删除tuneGrid。删除tuneGrid只需关闭交叉验证。

您正在打印
lda
,但您将结果分配给
lda2
。看起来这只是个打字错误。但在寻求帮助时,请确保包含包含示例数据的文档。由于我们的计算机上不存在该输入文件,因此无法运行此代码以查看问题所在。您正在打印
lda
,但您已将结果分配给
lda2
。看起来这只是个打字错误。但在寻求帮助时,请确保包含包含示例数据的文档。我们无法运行此代码来查看错误,因为我们的计算机上不存在该输入文件。
There are no tuning parameters for this model
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)
# summarize the model
print(model)