When we build binary classification models using algorithms like Neural Networks, XGBoost, Random Forests, etc., we get as an output of the models a prediction that ranges from 0 to 1. But how sure are we that this is a stable prediction? Does a score of 0.8 really mean 0.8? There is a difference between 0.8 +/- 0.05 and 0.8 +/- 0.4 after all!
One reason we love models grounded in statistics is that because of the strong assumptions they have, we can compute many metrics to provide insight into how sure we are the the coefficients are correct and what confidence intervals exist for model predictions. For example, see "Calculating Confidence Intervals for Logistic Regression" (https://stats.stackexchange.com/questions/354098/calculating-confidence-intervals-for-a-logistic-regression) or books like "Applied Linear Statistical Models" (https://a.co/d/a7BR3pa).
However, for other model types (non-parametric for example), we don't have the benefit of these kinds of measures. Over the past decade or more, when I've needed this kind of information, I've used bootstrap sample this way:
- Build my model. This is the baseline. For the testing data set, each record gets a score.
- Create 100 bootstrap samples of the training data.
- Build 100 models (one for each bootstrap sample) using same the protocol as the baseline model
- Run each model through the testing set. We now have 100 scores for every record in the test set...a distribution of scores
- compute the 90% confidence interval equivalent by identifying the probabilities (or model scores) at 5th and 95th percentiles (ranks 5 and 95 of the 100 scores). For the 95% confidence interval, one would need to interpolate between 2nd and 3rd, and also the 97th and 98th ranked scores