"Error in seeds[[num_rs + 1L]] : subscript out of bounds" 何时使用插入符创建 LVQ 模型?
"Error in seeds[[num_rs + 1L]] : subscript out of bounds" when using caret for creatng LVQ model?
我正在使用 caret 包创建 LVQ 模型和 select 包含 579 个自变量和 55 个样本的数据集的特征:
set.seed(123)
data=data
control <- trainControl(method="repeatedcv", number=5, repeats=10)
但是当我 运行 训练模型的命令时,我得到以下错误:
model <- train(remission~., data=data, method="lvq", preProcess="scale", trControl=control, importance=T)
Error in seeds[[num_rs + 1L]] : subscript out of bounds
你能提出任何解决方案吗?考虑到我拥有的变量数量,这似乎是为我的模型寻找重要特征的最佳方式。
我什至尝试将变量调整为 40 和 10,但我仍然遇到相同的错误。
生成网格的代码在小数据集上遇到了问题,你可以看看getModelInfo("lvq")$lvq$grid
下的代码,还有answered by the author of caret下的代码。您可以提供自己的网格,并注意 importance=TRUE
不是一个选项:
library(multtest)
library(caret)
data(golub)
data = data.frame(t(golub))
data$cl=factor(golub.cl)
control <- trainControl(method="cv", number=5)
model <- train(cl~., data=data, method="lvq", preProcess="scale",trControl=control)
Error in seeds[[num_rs + 1L]] : subscript out of bounds
TG = expand.grid(k=1:3,size=seq(5,20,by=5))
model <- train(cl~., data=data, method="lvq", preProcess="scale",trControl=control,tuneGrid=TG)
Learning Vector Quantization
38 samples
3051 predictors
2 classes: '0', '1'
Pre-processing: scaled (3051)
Resampling: Cross-Validated (5 fold)
Summary of sample sizes: 31, 30, 31, 29, 31
Resampling results across tuning parameters:
k size Accuracy Kappa
1 5 0.9527778 0.8967033
1 10 1.0000000 1.0000000
1 15 0.9492063 0.8929766
1 20 0.9206349 0.8461538
2 5 1.0000000 1.0000000
2 10 0.9206349 0.8321070
2 15 0.9555556 0.8800000
2 20 0.9714286 0.9391304
3 5 0.9492063 0.8929766
3 10 0.9555556 0.9000000
3 15 0.9777778 0.9538462
3 20 0.9527778 0.8967033
我正在使用 caret 包创建 LVQ 模型和 select 包含 579 个自变量和 55 个样本的数据集的特征:
set.seed(123)
data=data
control <- trainControl(method="repeatedcv", number=5, repeats=10)
但是当我 运行 训练模型的命令时,我得到以下错误:
model <- train(remission~., data=data, method="lvq", preProcess="scale", trControl=control, importance=T)
Error in seeds[[num_rs + 1L]] : subscript out of bounds
你能提出任何解决方案吗?考虑到我拥有的变量数量,这似乎是为我的模型寻找重要特征的最佳方式。 我什至尝试将变量调整为 40 和 10,但我仍然遇到相同的错误。
生成网格的代码在小数据集上遇到了问题,你可以看看getModelInfo("lvq")$lvq$grid
下的代码,还有answered by the author of caret下的代码。您可以提供自己的网格,并注意 importance=TRUE
不是一个选项:
library(multtest)
library(caret)
data(golub)
data = data.frame(t(golub))
data$cl=factor(golub.cl)
control <- trainControl(method="cv", number=5)
model <- train(cl~., data=data, method="lvq", preProcess="scale",trControl=control)
Error in seeds[[num_rs + 1L]] : subscript out of bounds
TG = expand.grid(k=1:3,size=seq(5,20,by=5))
model <- train(cl~., data=data, method="lvq", preProcess="scale",trControl=control,tuneGrid=TG)
Learning Vector Quantization
38 samples
3051 predictors
2 classes: '0', '1'
Pre-processing: scaled (3051)
Resampling: Cross-Validated (5 fold)
Summary of sample sizes: 31, 30, 31, 29, 31
Resampling results across tuning parameters:
k size Accuracy Kappa
1 5 0.9527778 0.8967033
1 10 1.0000000 1.0000000
1 15 0.9492063 0.8929766
1 20 0.9206349 0.8461538
2 5 1.0000000 1.0000000
2 10 0.9206349 0.8321070
2 15 0.9555556 0.8800000
2 20 0.9714286 0.9391304
3 5 0.9492063 0.8929766
3 10 0.9555556 0.9000000
3 15 0.9777778 0.9538462
3 20 0.9527778 0.8967033