Classifying using logistic regression

The stats package contains the glm function for classification using logistic regression.

Getting ready

If you have not already installed the caret package, install it now. Download the data files for this chapter from the book's website and place the boston-housing-logistic.csv file in your R working directory. We will use CLASS as our target or outcome variable, and all the remaining variables as predictors. Our outcome variable has values of 0 or 1, with 0 representing neighborhoods with "Low" median home values and 1 representing neighborhoods with "High" median home values. Logistic regression requires all the independent/predictor variables to be numeric, and the dependent variable or outcome to be categorical ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.