Predicting with logistic regression
The next step is to do some analytics also in R. I will start with logistic regression. First, we need to read the data in R:
library(RODBC) con <- odbcConnect("AWDW", uid = "RUser", pwd = "Pa$$w0rd") TM <- sqlQuery(con, "SELECT CustomerKey, CommuteDistance, TotalChildren, NumberChildrenAtHome, Gender, HouseOwnerFlag, NumberCarsOwned, MaritalStatus, Age, Region, Income, Education, Occupation, BikeBuyer, TrainTest FROM dbo.TMTrain UNION SELECT CustomerKey, CommuteDistance, TotalChildren, NumberChildrenAtHome, Gender, HouseOwnerFlag, NumberCarsOwned, MaritalStatus, Age, Region, Income, Education, Occupation, BikeBuyer, TrainTest FROM dbo.TMTEST") close(con)
The next step, similar to Python, is to define the factors and their levels accordingly:
# Define Education as ordinal TM$Education = factor(TM$Education, order = TRUE, levels = c("Partial High School", "High School", "Partial College", "Bachelors", "Graduate Degree")) # Define...