Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的caretStack-未使用的参数_R_R Caret_Ensemble Learning_Ensembles - Fatal编程技术网

R中的caretStack-未使用的参数

R中的caretStack-未使用的参数,r,r-caret,ensemble-learning,ensembles,R,R Caret,Ensemble Learning,Ensembles,我在R中做了一堆模型,如下所示: ctrl <- trainControl(method="repeatedcv", number=5, repeats=3, returnResamp="final", savePredictions="final", classProbs=TRUE, selectionFunction="oneSE", verboseIter=TRUE) models_stack <- caretStack( model_list, data=train

我在R中做了一堆模型,如下所示:

ctrl <- trainControl(method="repeatedcv", number=5, repeats=3, returnResamp="final", savePredictions="final", classProbs=TRUE, selectionFunction="oneSE", verboseIter=TRUE)

models_stack <- caretStack(
  model_list,
  data=train_data,
  tuneLength=10,
  method="glmnet",
  metric="ROC",
  trControl=ctrl
)
2) 是否不应该有“数据”参数?如果我需要为我的1级主管模型使用不同的数据集,我可以做什么

3) 我还想使用AUC/ROC,但出现了这些错误

The metric "AUC" was not in the result set. Accuracy will be used instead.

我在网上看到了一些ROC可以使用的例子,是不是因为它不适合这个模型?除了此模型的准确性之外,我还可以使用哪些指标?如果我需要使用ROC,还有哪些选项

按照@RLave的要求,我的型号列表就是这样完成的

grid.xgboost <- expand.grid(.nrounds=c(40,50,60),.eta=c(0.2,0.3,0.4),                
.gamma=c(0,1),.max_depth=c(2,3,4),.colsample_bytree=c(0.8),                
.subsample=c(1),.min_child_weight=c(1))

grid.rf <- expand.grid(.mtry=3:6)

model_list <- caretList(y ~.,
                    data=train_data_0,
                    trControl=ctrl,
                    tuneList=list(
                      xgbTree=caretModelSpec(method="xgbTree", tuneGrid=grid.xgboost),
                      rf=caretModelSpec(method="rf", tuneGrid=grid.rf)
                    )
  )

grid.xgboost您的问题包含三个问题:

  • 为什么我会看到以下错误?我能做什么?我现在卡住了
  • caretStack
    不应具有
    数据
    参数,
    数据
    是根据
    caretList
    中的模型预测生成的。看看这个可重复的例子:

    library(caret)
    library(caretEnsemble)
    library(mlbench)
    
    使用声纳数据集:

    data(Sonar)
    
    为xgboost的超参数优化创建网格:

    grid.xgboost <- expand.grid(.nrounds = c(40, 50, 60),
                                .eta = c(0.2, 0.3, 0.4),                
                                .gamma = c(0, 1),
                                .max_depth = c(2, 3, 4),
                                .colsample_bytree = c(0.8),                
                                .subsample = c(1), 
                                .min_child_weight = c(1))
    

    grid.xgboost@RLave嗨,我已经完成了更新
    
    data(Sonar)
    
    grid.xgboost <- expand.grid(.nrounds = c(40, 50, 60),
                                .eta = c(0.2, 0.3, 0.4),                
                                .gamma = c(0, 1),
                                .max_depth = c(2, 3, 4),
                                .colsample_bytree = c(0.8),                
                                .subsample = c(1), 
                                .min_child_weight = c(1))
    
    grid.rf <- expand.grid(.mtry = 3:6)
    
    ctrl <- trainControl(method="cv",
                         number=5,
                         returnResamp = "final",
                         savePredictions = "final",
                         classProbs = TRUE,
                         selectionFunction = "oneSE",
                         verboseIter = TRUE,
                         summaryFunction = twoClassSummary)
    
    model_list <- caretList(Class ~.,
                            data = Sonar,
                            trControl = ctrl,
                            tuneList = list(
                              xgbTree = caretModelSpec(method="xgbTree",
                                                       tuneGrid = grid.xgboost),
                              rf = caretModelSpec(method = "rf",
                                                  tuneGrid = grid.rf))
    )
    
    models_stack <- caretStack(
      model_list,
      tuneLength = 10,
      method ="glmnet",
      metric = "ROC",
      trControl = ctrl
    )