k-fold cross validation with modelr and broom
@drsimonj here to discuss how to conduct k-fold cross validation, with an emphasis on evaluating models supported by David Robinson’s broom package. Full credit also goes to David, as this is a slightly more detailed version of his past post, which I read some time ago and felt like unpacking.
Assumed knowledge: K-fold Cross validation
This post assumes you know what k-fold cross validation is. If you want to brush up, here’s a fantastic tutorial from Stanford University professors Trevor Hastie and Rob Tibshirani.
Before worrying about models, we can generate K folds using
crossv_kfold from the modelr package. Let’s practice with the
mtcars data to keep things simple.
library(modelr) set.seed(1) Run to replicate this post folds <- crossv_kfold(mtcars, k = 5) folds > A tibble: 5 × 3 > train test .id > <list> <list> <chr> > 1
Continue reading →