Tidy up the coefficients of your models
In this exercise you will leverage the list column workflow along with the tidy() function from broom to extract and explore the coefficients for the 77 models you built.
Remember the gap_models data frame contains a model predicting life expectancy by year for 77 countries.
Это упражнение является частью курса
Machine Learning in the Tidyverse
Инструкции к упражнению
- Use
tidy()to append a column (coef) containing coefficient statistics for each model to thegap_modelsdata frame and save it asmodel_coef_nested. - Simplify this data frame using
unnest()to extract these coefficients in your data frame. - Explore the coefficient estimates for the year feature across your 77 models by plotting a histogram of their values.
Интерактивное практическое упражнение
Попробуйте выполнить это упражнение, дополнив этот пример кода.
# Extract the coefficient statistics of each model into nested data frames
model_coef_nested <- gap_models %>%
mutate(coef = map(model, ~___(.x)))
# Simplify the coef data frames for each model
model_coef <- model_coef_nested %>%
unnest(___)
# Plot a histogram of the coefficient estimates for year
model_coef %>%
filter(term == "___") %>%
ggplot(aes(x = ___)) +
geom_histogram()