student
student

Reputation: 999

Using ranger method caret train function

I am having trouble using ranger with caret to predict probabilities. Here is my code:

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

This returns the following error(s), warning(s), and message(s).

## 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)

Running it outside of caret works though.

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

Upvotes: 2

Views: 5021

Answers (1)

discipulus
discipulus

Reputation: 2715

Put classProbs inside trControl as in:

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

Upvotes: 4

Related Questions