My goal is to save the model as an input object for an R Shiny app and then for a new subject, insert inputs in the app, and calculate predicted probabilities and associated 95% CI (or prediction intervals).
I did the following to save the model.
RF.up.samp <- train(PTDCategory_12m ~ X1 + X2 + X3 + X4 + X5 + X6, method = "ranger",
data = training.data,
metric = "ROC",
trControl = trainControl(method = "boot",
sampling = "up",
#savePredictions = TRUE,
summaryFunction = twoClassSummary,
classProbs = TRUE), na.action=na.exclude)
saveRDS(RF.up.samp, "./final_model.rds")
But I can only get a predicted probability using the option type="prob"
in the predict()
function for each class. How do I get the 95% CI of the predicted probability like, for example, [p.hat.lower, p.hat.upper]
?