Slide 49
Slide 49 text
predict_split function(assess_data, model) {
predict(model, new_data = assess_data)
}
cv_splits cv_splits %>%
mutate(
assess = map(splits, assessment),
preds = map2(assess, models, predict_split)
)
select(cv_splits, id, assess, preds)
# 10-fold cross validation using stratification
# A tibble: 10 x 3
id assess preds
*
1 Fold01
2 Fold02
3 Fold03
4 Fold04
5 Fold05
6 Fold06
7 Fold07
8 Fold08
9 Fold09
10 Fold10
Resampled predictions
At this point, we have fit models to each analysis set, and we can now make predictions for each resample using the corresponding
assessment set.
The same map() approach applies. We also use map2() to map over 2 things at once: the assessment set and the model. Both of
these are used together to create the predictions.
38 / 42