Lab 4E
Directions: Follow along with the slides, completing
the questions in blue on your
computer, and answering the questions in red in your
journal.
Space, Click, Right Arrow or swipe left to move to
the next slide.
movie
data and split it into two sets:
training
that includes
75% of the data.test
that includes
the remaining 25%.set.seed
.audience_rating
based on critics_rating
for
the training
data. Assign this model to
movie_linear
.audience_rating
on the y-axis and
critics_rating
on the x-axis using your test
data.add_line
to plot the line of
best fit. An alternative function for plotting the line of best
fit is add_curve
, which takes the name of the model as
an argument.training
data to the plot.critics_rating
that would make obviously
poor predictions?
critics_rating
?test
data and write it down for later.
y = a + bx
y = a + bx + cx
2
y = a + bx + cx
2
+ dx
3
R
, we can use the
poly()
function.
audience_rating
from
critics_rating
, and assign that model to
movie_quad
.2
in the
poly()
function?audience_rating
on the y-axis and
critics_rating
on the x-axis using your test
data, andcol
argument is added to the
add_curve
functions to help distinguish the two
curves.test
MSE?test
data and write it down for later.test
MSE to explain why one model fits
better than the other.audience_rating
using a cubic curve (polynomial with degree
3
), and assign this model to
movie_cubic
.audience_rating
on the y-axis and
critics_rating
on the x-axis using your test
data.training
data to the plot.test
data?test
MSE to verify which model is the
best at predicting the test
data.