Augmenting your data
From the results of glance()
, you learned that using the available features the linear model fits well with an adjusted \(R^2\) of 0.99. The augment()
function can help you explore this fit by appending the predictions to the original data.
Here you will leverage this to compare the predicted values of life_expectancy
with the original ones based on the year
feature.
Cet exercice fait partie du cours
Machine Learning in the Tidyverse
Instructions
- Build the augmented data frame
algeria_fitted
usingaugment()
. - Visualize the fit of the model with respect to
year
by plotting bothlife_expectancy
as points and.fitted
as a line.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Build the augmented data frame
algeria_fitted <- ___
# Compare the predicted values with the actual values of life expectancy
algeria_fitted %>%
ggplot(aes(x = ___)) +
geom_point(aes(y = ___)) +
geom_line(aes(y = ___), color = "red")