Get startedGet started for free

What are the coefficients?

To get a good feel for the difference between fitted model parameters and hyperparameters, we are going to take a closer look at those fitted parameters: in our simple linear model, the coefficients. The dataset breast_cancer_data has already been loaded for you and the linear model call was run as in the previous lesson, so you can directly access the object linear_model.

In our linear model, we can extract the coefficients in the following way: linear_model$coefficients. And we can visualize the relationship we modeled with a plot.

Remember, that a linear model has the basic formula: y = x * slope + intercept

This exercise is part of the course

Hyperparameter Tuning in R

View Course

Exercise instructions

  • Explore the coefficients of the linear_model in the console.
  • Plot the regression line with ggplot2.
  • Assign the correct coefficients to slope and intercept.

Hands-on interactive exercise

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

library(ggplot2)

# Plot linear relationship.
ggplot(data = breast_cancer_data, 
        aes(x = symmetry_mean, y = concavity_mean)) +
  geom_point(color = "grey") +
  ___(slope = ___$___[___], 
      intercept = ___$___[___])
Edit and Run Code