r - How does caret train determine the probability threshold to maximise Specificity -
i using caret's twoclasssummary function determine optimal model hyper-parameters maximise specificity. however, how function determine probability threshold maximises specificity?
does caret each model hyper-parameter/fold evaluate every threshold between 0 , 1 , returns maximum specificity? in example below can see model has landed on cp = 0.01492537.
# load libraries library(caret) library(mlbench) # load dataset data(pimaindiansdiabetes) # prepare resampling method control <- traincontrol(method="cv", number=5, classprobs=true, summaryfunction=twoclasssummary) set.seed(7) fit <- train(diabetes~., data=pimaindiansdiabetes, method="rpart", tunelength= 5, metric="spec", trcontrol=control) print(fit) cart 768 samples 8 predictor 2 classes: 'neg', 'pos' no pre-processing resampling: cross-validated (5 fold) summary of sample sizes: 614, 614, 615, 615, 614 resampling results across tuning parameters: cp roc sens spec 0.01305970 0.7615943 0.824 0.5937806 0.01492537 0.7712055 0.824 0.6016073 0.01741294 0.7544469 0.830 0.5976939 0.10447761 0.6915783 0.866 0.5035639 0.24253731 0.6437820 0.884 0.4035639 spec used select optimal model using largest value. final value used model cp = 0.01492537.
Comments
Post a Comment