Skip to content

Commit 32101bd

Browse files
authored
Merge pull request #589 from tidymodels:calibration-article-bootstrap
add explanation of calibration split for bootstrap
2 parents c264411 + 9a0dbf6 commit 32101bd

5 files changed

Lines changed: 23 additions & 0 deletions

File tree

inst/calibration-sets.Rmd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,26 @@ split_cal <- internal_calibration_split(chicago_r_split, .get_split_args(chicago
359359
chicago_cal <- calibration(split_cal)
360360
range(chicago_cal$date)
361361
```
362+
363+
## Splits for bootstrap samples
364+
365+
For bootstrap samples, our goal of avoiding overfitting means we need to refine our approach to making calibration splits a little further.
366+
367+
If our (outer) analysis set is a bootstrap sample of the training data, it likely contains several replications of an observation.
368+
369+
![](images/bootstrap-resample.jpg)
370+
371+
We don't want those to be split up into the inner analysis and the calibration set. Simply creating another bootstrap resample from the (outer) analysis set makes it likely for this to happen. In the example illustration below, the third row (`2-1`) of the (outer) analysis set is sampled twice into the (inner) analysis set. The fourth (`2-2`) and fifth (`2-3`) row are not sampled and thus are put into the calibration set. However, all those rows are actually the same row, hence we have the same row in both the (inner) analysis set and the calibration set.
372+
373+
![](images/bootstrap-regular.jpg)
374+
375+
To avoid this, we could do a grouped resampling with the row ID as the group. Then all replications of a row would end up in the same set, either (inner) analysis or calibration. However, this would mean that rows in the calibration set are potentially not unique, unlike the typical bootstrap OOB sample.
376+
377+
![](images/bootstrap-grouped.jpg)
378+
379+
To prevent both these potential issues, we create the calibration split by sampling the (inner) analysis set, with replacement, from the pool of unique rows in the (outer) analysis set.
380+
381+
![](images/bootstrap-modified.jpg)
382+
383+
384+

inst/images/bootstrap-grouped.jpg

129 KB
Loading

inst/images/bootstrap-modified.jpg

109 KB
Loading

inst/images/bootstrap-regular.jpg

147 KB
Loading

inst/images/bootstrap-resample.jpg

94.2 KB
Loading

0 commit comments

Comments
 (0)