Get startedGet started for free

Best and worst fitting models

In this exercise you will answer the following questions:

  • Overall, how well do your models fit your data?
  • Which are the best fitting models?
  • Which models do not fit the data well?

This exercise is part of the course

Machine Learning in the Tidyverse

View Course

Exercise instructions

  • Plot a histogram of the \(R^2\) values of the 77 models
  • Extract the 4 best fitting models (based on \(R^2\)) and store this data frame as best_fit
  • Extract the 4 worst fitting models (based on \(R^2\)) and store this data frame as worst_fit

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot a histogram of rsquared for the 77 models    
model_perf %>% 
  ggplot(aes(x = ___)) + 
  ___()  
  
# Extract the 4 best fitting models
best_fit <- model_perf %>% 
  slice_max(___, n = ___)

# Extract the 4 models with the worst fit
worst_fit <- model_perf %>% 
  slice_min(___, n = ___)
Edit and Run Code