Multiple Regression

13. Multiple Regression#

This chapter builds on the simple regression of Chapter 12 and frames it as machine learning: models with several predictors, fit with scikit-learn and judged on test data. You will interpret coefficients, assess model assumptions, evaluate prediction quality with training and testing data, and learn to avoid overfitting, all with real home sales from Ames, Iowa.

  • Multiple Regression: A linear model with several predictors at once, so each feature’s effect can be read while the others are held fixed.

  • Coefficients: Each coefficient is the expected change in the target for a one-unit increase in that predictor, holding the other predictors constant.

  • Multicollinearity: When predictors are strongly related to each other, the model struggles to separate their effects and individual coefficients are harder to interpret.

  • Regression with scikit-learn: A feature matrix X, a target y, a train/test split, and LinearRegression().fit turn the Chapter 12 least squares idea into a reusable prediction workflow.

  • Train and Test Data: Fitting on training data and judging on held-out test data shows how well the model predicts new cases.

  • Error Metrics: MAE, RMSE, and R-squared summarize prediction error and explained variation, and residual plots reveal patterns the metrics miss.

  • Overfitting and Validation: Training error always falls as features are added, so features are chosen on a validation set or by cross-validation, and the test set is used once, at the end.

Chapter Video

Video credit: StatQuest with Josh Starmer. (2017, October 30). Multiple Regression, Clearly Explained!!!. YouTube. Watch on YouTube (5:25).

This embedded video is provided for educational reference only. All rights are retained by the respective copyright holder.

Learning Objectives

By the end of this chapter, you will be able to:

  1. Explain how multiple regression extends simple linear regression.

  2. Fit a regression model with scikit-learn from a feature matrix and a target, using a train/test split.

  3. Interpret regression coefficients while holding other predictors fixed.

  4. Recognize multicollinearity and other modeling assumptions.

  5. Evaluate model quality with errors and train/test comparisons.

  6. Use multiple regression for applied prediction and explanation questions.

  7. Recognize overfitting and choose features with a validation set, weighing accuracy against interpretability.

Chapter Flow

Glossary

#

Term

Explanation

1

Multiple regression

Regression with more than one predictor.

2

Predictor

An input variable used in a model.

3

Target

The outcome variable being modeled.

4

Coefficient

A model parameter attached to a predictor.

5

Intercept

The predicted target when all predictors equal zero.

6

Holding constant

Interpreting one predictor while other predictors stay fixed.

7

Feature matrix

A table of predictor values used for modeling.

8

Response vector

The target values used for modeling.

9

Multicollinearity

Strong association among predictors.

10

Additivity

A model assumption that predictor effects combine by addition.

11

Linearity

A model assumption that relationships are represented by straight-line effects.

12

Residual

Observed value minus predicted value.

13

Residual diagnostic

A check based on residual patterns.

14

Training data

Data used to fit a model.

15

Test data

Data reserved to evaluate model performance.

16

Mean squared error

Average squared prediction error.

17

Root mean squared error

Square root of mean squared prediction error.

18

R-squared

The proportion of outcome variation explained by a model.

19

Overfitting

When a model fits training data too closely and generalizes poorly.

20

Interpretability

How easily a model can be explained.

21

Prediction pipeline

The steps used to prepare data, fit a model, and evaluate predictions.

22

Machine learning

Methods that use data to make predictions, detect patterns, or support decisions.

23

Train-test split

Dividing the rows at random into a training set and a test set.

24

Validation set

Data held out to compare modeling choices before the final test.

25

Mean absolute error

Average absolute prediction error, in the units of the target.

26

Loss function

A measure of prediction error that model fitting tries to make small.

27

Nearest neighbor regression

Predicting a target as the average of the most similar training cases.

28

Correlation matrix

A table of the correlation r for every pair of columns.

29

Feature selection

Choosing which predictors to include in a model.

30

Interaction

A product of two features, so that one feature’s effect on the target depends on the other.

31

Cross-validation

Splitting the labeled data into folds, letting each fold serve once as the validation set, and averaging the results.

Lecture Slides