Beginner level · Module 3: First Models: Regression and Classification · Lesson 1 of 3
Linear Regression
Predict a number with a straight-line model and read what its coefficients say.
In this lesson you will
- Train a linear regression model and make predictions
- Interpret coefficients and compare with a baseline
Key concepts
linear regressioncoefficient and interceptbaselineresidual
The lesson
Linear regression predicts a number as a weighted sum of the features: yield = intercept + 2.1 × rainfall_cm + … . Each coefficient says how much the prediction changes when that feature increases by one unit, other features held constant.
Always compare with a baseline, such as always predicting the average. If the model cannot beat the average, it has learned nothing useful.
Coefficients describe association in this data, not cause and effect. Rainfall and yield may move together for other reasons, such as fertiliser use in wetter areas.
Step by step
- Train LinearRegression on the crop-yield data.
- Print and interpret the coefficients.
- Compare its error with predicting the mean.
- Plot predicted against actual yields.
Practice activity
Build a crop-yield regression model and explain its two most important coefficients in plain language.
Expected result: A model that beats the mean baseline, with correct, cautious interpretations of its coefficients.
Check your understanding
-
What does a regression coefficient tell you?
Show answer
How much the prediction changes per unit increase in that feature, other features held constant.
-
Do coefficients prove cause and effect?
Show answer
No; they show association in the data.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.