Lineaire regressie, interactief
An interactive chapter on linear regression using Amsterdam house prices. You make your own prediction first, complete the Python code and compare the model with and without the largest houses.
- Role
- Owner of the linear regression chapter
- Context
- An interactive lesson on linear regression
- Stack
- Python and scikit-learn
What it's for
At the HvA, a group of students built one interactive web app on classical machine learning, in which each student makes their own chapter. In every chapter you work with a real, running model instead of only text and pictures.
What I built
I made the chapter on linear regression, in seven steps. It uses 920 houses that were for sale in Amsterdam in 2021, with their floor area and asking price.
First you predict how much more expensive a house gets per extra square metre. Then you complete the Python code with which a real scikit-learn model calculates the line, and you read the slope and the intercept from the model. You immediately see whether your prediction was right.
In the last step you compare the model with and without the eleven largest houses. That shows how a few extreme points can tilt the whole line.
Gallery
3
The regression line the model fits through 920 Amsterdam houses, with the slope and R²
Step 4: completing the Python code that makes the model learn the line
Step 7: the model with all houses next to the model without the largest houses