Decision curve analysis (DCA) for Random forest (RF)

Does anyone know how to perform a decision curve analysis for a random forest? I could not find any codes on the internet, even though i read papers that report this. I used the caret package to create my model and thought maybe through the predict function i could get the necessary information, however, this does not work. Really appreciate any help, especially as there seems to be no information available!

This is what i tried (model was tuned before)

tunegrid <- expand.grid(.mtry=mtry)

model <- train(
  Lymph_node_involvement ~ predictors,
  data = train.data,
  method = "rf",
  ntree = 800,
  preProcess = c("scale", "center"),
  tuneGrid = tunegrid,
  trControl = trainControl(
    method = "cv",
    summaryFunction = twoClassSummary,
    classProbs = T,
    savePredictions = T,
  ),
  importance = TRUE,
  metric = "ROC"
)

LNIClasses <- predict(model, newdata = test.data, type="raw")
LNIClasses <- as.data.frame(LNIClasses )
result2 = dca(data="test.data", outcome="Lymph_node_involvement", predictors="LNIClasses ", smooth="TRUE", xstop=0.50)``

Hi @VictorM,

You should be able to get fitted probabilities from your random forest model. Using these, you should be able to use the dca() function with the option probability = TRUE

dca(
  data="test.data", 
  outcome="Lymph_node_involvement", 
  predictors = "whatever_you_name_this_var",
  probability = TRUE
  <<whatever other options you want>>
)

Probabilities are preferred for performance metrics over hard-coded classes. Let me know if this doesn't work for you.

Thanks, i got it working!

Best regards!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.