liveBook · Manning

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

What you will learn in chapter 8 of Grokking Statistics

The introduction distinguishes classification from predicting continuous values and introduces logistic regression as a way to predict a label using a probability.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction distinguishes classification from predicting continuous values and introduces logistic regression as a way to predict a label using a probability.

Key terms: classification, categorical, binary classification, linear regression, continuous value, logistic regression, probability, label

8.1 Logistic regression

Introduces logistic regression as a way to predict the probability of a classification from an input variable.

Key terms: logistic regression, probability, label/classification, input variable

8.2 Logistic regression intuition

This section uses a toddler-meltdown example to show how logistic regression turns binary observations into predicted probabilities and, with a threshold, yes-or-no predictions.

Key terms: independent variable, output variable, binary, probability, linear regression, S-shaped curve, sigmoid function, logistic function, inflection point, probability threshold

8.3 Logistic regression in Python

This section shows how to fit a logistic regression in Python, interpret its S-shaped probability curve, and use the fitted model to predict a new case.

Key terms: logistic function, sigmoid function, β0, β1, x, maximum likelihood estimation, least squares, fit, scikit-learn, LogisticRegression

8.4 Understanding the log-odds

This section shows how log-odds make logistic regression’s linear component interpretable and how an odds ratio compares predicted risks at two input values.

Key terms: odds, log-odds, logit function, linear component, 1:1, odds ratio

8.5 Verifying classification models

The section explains why a fitted logistic regression model must be checked on unseen data and why it uses a machine-learning approach to do so.

Key terms: generalization, overfitting, train/test splits, cross-validation, validation, machine-learning approach, correlation coefficients, p-values, McFadden’s pseudo-R2, 𝜒2 distribution

8.6 Train/test splits

The section shows how to test a classification model on held-out data and use repeated tests to assess how consistently it predicts unseen cases.

Key terms: train/test split, training dataset, test dataset, train_test_split(), fit(), predict(), k-fold cross-validation, three-fold cross-validation, standard deviation, unseen data

8.7 False positives and false negatives

This section uses a wolf alarm to explain the four possible classification outcomes and why the costs of its two kinds of error matter.

Key terms: false positive, FP, Type I error, false negative, FN, Type II error, false alarms, missed alarms, false positives, false negatives

8.8 Confusion matrices: Why accuracy is misleading

The section uses a confusion matrix to show why 98% accuracy can conceal a wolf detector that never detects a wolf.

Key terms: confusion matrix, true positives (TP), false positives (FP), true negatives (TN), false negatives (FN), accuracy, class imbalance, true positives, true negatives

8.9 Precision and recall

The section explains how precision and recall reveal a classifier’s success at detecting positive cases, why they can trade off, and why a single combined score may not fit a business decision.

Key terms: precision, recall, true negatives, positive cases, accuracy, class imbalance, false alarms, missed alarms, threshold, F-measure

8.10 Validation in practice

The section shows how to evaluate a classification model across thresholds and choose a threshold that fits the costs of missed events and false alarms.

Key terms: threshold, precision, recall, false positives, false negatives, receiver operating characteristic (ROC) curve, false-positive rate (FPR), true positive rate (TPR), predicted probabilities, predicted classes

8.11 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 7: Number go up (or down)! Correlation and linear regression Chapter 9: Crimes against data: Statistics done wrong →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.