【问题标题】:"Something is wrong; all the Accuracy metric values are missing" while using partykit, caret, recipes使用partykit、插入符号、食谱时“出现问题;所有准确度指标值都丢失”
【发布时间】:2021-04-01 07:09:17
【问题描述】:

我正在尝试使用食谱(用于一致的预处理)和插入符号(用于一致的训练)训练大约 15 个机器学习模型。只有 2 个模型始终给我错误“出了点问题;所有准确度指标值都丢失了”在partykit 包中——cforest 和 ctree。 下面我使用来自 mlbench 的 PimaIndiansDiabetes 数据集显示错误。

my_rec <- recipe(diabetes ~ ., data = PimaIndiansDiabetes) %>%
  step_dummy(all_nominal(), -diabetes)%>%
  step_nzv(all_predictors())

fitControl5 <- trainControl(summaryFunction = twoClassSummary, 
                             verboseIter = TRUE, 
                             savePredictions =  TRUE, 
                             sampling = "smote", 
                             method = "repeatedcv", 
                             number= 5, 
                             repeats = 1,
                             classProbs = TRUE)

dtree5 <- train(my_rec, data = PimaIndiansDiabetes,
                 method = "cforest",
                 metric = "Accuracy",
                 tuneLength = 8,
                 trainControl = fitControl5)

note: only 7 unique complexity parameters in default grid. Truncating the grid to 7 .

Something is wrong; all the Accuracy metric values are missing:
    Accuracy       Kappa    
 Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA  
 NA's   :7     NA's   :7    
Error: Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)

下面是方法 ctree 的代码

dtree6 <- train(my_rec, data = PimaIndiansDiabetes,
                 method = "ctree",
                 metric = "Accuracy",
                 tuneLength = 8,
                 trainControl = fitControl5)
Something is wrong; all the Accuracy metric values are missing:
    Accuracy       Kappa    
 Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA  
 NA's   :8     NA's   :8    
Error: Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)

非常感谢您的帮助!

【问题讨论】:

  • 使用库(mlbench),我仍然得到错误:错误:找不到对象'PimaIndiansDiabetes'

标签: r r-caret ctree


【解决方案1】:

参数应该是 trControl = 而不是 trainControl = 。如果我运行以下它可以工作:

dtree5 <- train(my_rec, data = PimaIndiansDiabetes,
                  method = "cforest",
                  metric = "Accuracy",
                  tuneLength = 3,
                  trControl = fitControl5)

输出:

dtree5
Conditional Inference Random Forest 

768 samples
  8 predictor
  2 classes: 'neg', 'pos' 

Recipe steps: dummy, nzv 
Resampling: Cross-Validated (5 fold, repeated 1 times) 
Summary of sample sizes: 614, 615, 614, 615, 614 
Addtional sampling using SMOTE

Resampling results across tuning parameters:

  mtry  ROC        Sens   Spec     
  2     0.8298281  0.788  0.7013277
  5     0.8256038  0.794  0.7013277
  8     0.8222572  0.798  0.7276031

ROC was used to select the optimal model using the largest value.
The final value used for the model was mtry = 2.

【讨论】:

    猜你喜欢
    • 2015-08-09
    • 2016-07-10
    • 2016-01-10
    • 2017-09-29
    • 1970-01-01
    • 2015-08-14
    • 2020-11-30
    • 2016-12-21
    • 2015-09-01
    相关资源
    最近更新 更多