Question: # Questions in Bold # 1 Load the data set mtcars into memory and convert column am to a factor # using factor() function mtcars$am
# Questions in Bold
# 1 Load the data set mtcars into memory and convert column am to a factor # using factor() function mtcars$am mtcars$am = factor(mtcars$am) head(mtcars$am) glm.fit = glm(am ~ mpg + cyl + hp + wt, data = mtcars, family="binomial") summary(glm.fit)
# 2 Split the data into training set and test set. The training set contains the # first 35 observations, the test set containing the remaining observations
How do you specify a specific number of observations? train = mtcars$name = mtcars.test = mtcars[! train,]
# 3 Build a logistic regression model with the response is am and the # predictors are mpg, cyl, hp, and wt using glm() function glm.fit = glm(am ~ mpg + cyl + hp + wt, data = mtcars,family = "binomial", subset = train)
# 4 Compute the test error on the test data set using a confusion matrix. # Is it a good model based on test error?
Dataset via https://github.com/MyGitHub2120/mtcars
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
