chapter eight

8 Yes, no, or maybe so? Logistic regression and classification

 

In this chapter

  • Classification models and their distinction from regressions
  • How to perform logistic regression and validate classification models
  • The machine learning workflow and its distinction from traditional statistics

Classifying means choosing a label for something, such as whether an email is spam or not spam, or whether an image contains a dog, cat, or bird. When we classify a prediction or outcome, we are not predicting a continuous value (e.g., 103.5 degrees Fahrenheit) but rather a binary (spam/not spam) or multiple-choice (dog/cat/bird) outcome. We also call this type of problem categorical or consider it a form of classification. Linear regression is not necessarily equipped for this type of problem because we need a qualitative value (e.g., is this email spam?) from a limited set of values (spam or not spam). This chapter emphasizes examples with binary classification (e.g., spam or not spam). Although these techniques also lend themselves to modeling multiple classes (e.g., dog/cat/bird), multiclass classification is outside the scope of this book.

Logistic regression

Logistic regression intuition

Logistic regression in Python

Understanding the log-odds

Verifying classification models

Train/test splits

False positives and false negatives

Confusion matrices: Why accuracy is misleading

Precision and recall

Validation in practice

Summary