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
Cet exercice fait partie du cours
Hyperparameter Tuning in R
Instructions
- Explore the coefficients of the
linear_model
in the console. - Plot the regression line with
ggplot2
. - Assign the correct coefficients to
slope
andintercept
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
library(ggplot2)
# Plot linear relationship.
ggplot(data = breast_cancer_data,
aes(x = symmetry_mean, y = concavity_mean)) +
geom_point(color = "grey") +
___(slope = ___$___[___],
intercept = ___$___[___])