在R中使用插入符号的ANN模型训练中的错误

时间:2018-07-20 13:41:08

标签: r r-caret

我正在尝试使用插入符号包训练ANN模型。但是,我收到以下错误。不明白为什么。任何帮助表示赞赏。

我的“ train_data”数据帧有16行和17列,包括响应和16个预测变量。

Error in `$<-.data.frame`(`*tmp*`, "y", value = numeric(0)) : 
      replacement has 0 rows, data has 10



    set.seed(153)
    log.seeds <- vector(mode = "list",length = 11) 
    for(i in 1:10) log.seeds[[i]] <- sample.int(1000, 6) 
   # .decay = c(0.5,0.1) = 2, .size = c(5,6,7) = 3, So, 2 * 3 = 6
    # for the last model
    log.seeds[[11]] <- sample.int(1000,1)



train_data <- data.frame(train_data)
registerDoSEQ()
my.grid <- expand.grid(.decay = c(0.5,0.1), .size = c(5,6,7))
ctrl <- trainControl(method = "cv",number = 10, classProbs = TRUE, summaryFunction = twoClassSummary, allowParallel = TRUE) 
model_lm <- train(train_data[,-1],train_data[,1], method = "nnet",maxit = 1000,metric = "RMSE", tuneGrid = my.grid, trace = FALSE, linout = TRUE, trControl = ctrl, verbose = FALSE)

0 个答案:

没有答案