【问题标题】:Using ranger method caret train function使用 ranger 方法 caret train 函数
【发布时间】:2017-07-20 05:42:16
【问题描述】:

我无法使用带有插入符号的游侠来预测概率。这是我的代码:

model <- train(Species ~ .,
               data = iris,
               method = "ranger",
               probability = TRUE)

这将返回以下错误、警告和消息。

## 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   :6     NA's   :6    
## Error: Stopping
## In addition: There were 50 or more warnings (use warnings() to see the first 50)

但在插入符号之外运行它是可行的。

ranger(Species ~ ., data = iris, probability = TRUE)

【问题讨论】:

    标签: r r-caret


    【解决方案1】:

    classProbs 放入trControl 中,如下所示:

    model <- train(
      Species  ~ .
      ,data = iris
      ,method = "ranger"
      ,trControl = trainControl(classProbs=TRUE)
    )
    

    【讨论】:

    • 然后我可以使用:`predict(model, iris, type = "prob") 来获得概率。谢谢。
    猜你喜欢
    • 2014-05-23
    • 2018-03-16
    • 1970-01-01
    • 2021-03-28
    • 2015-12-28
    • 1970-01-01
    • 2018-03-11
    • 2017-06-01
    • 2016-12-16
    相关资源
    最近更新 更多