Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this problem, you will develop a model to predict whether a given car gets high or low gas mileage based on the Auto data
In this problem, you will develop a model to predict whether a given car gets high or
low gas mileage based on the Auto data set.
a Create a binary variable, that contains a if contains a value above
its median, and a if contains a value below its median. You can compute the
median using the median function. Note you may find it helpful to use the
dataframe function to create a single data set containing both and the
other Auto variables.
b Explore the data graphically in order to investigate the association between
mpg and the other features. Which of the other features seem most likely to be
useful in predicting Scatterplots and boxplots may be useful tools to
answer this question. Describe your findings.
c Split the data randomly into a training set and a test set Make sure
to use set seed for reproducible results.
d Perform KNN on the training data, with several values of in order to predict
mpg Use only the variables that seemed most associated with mpg in b
What test errors do you obtain? Which value of seems to perform the best on
this data set?
e Are the predictors you included into KNN model on the same scale? Proceed to
scale the train & test data from parts as we did in the lab. Only use the
predictors that you claimed to be useful in explaining Repeat part for
the scaled data.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started