In this lesson it's finally time to train our model. 1
We're going to model our house prices using a technique called multivariable regression which is also 2
known as multiple linear regression. 3
But what does that mean? 4
In a previous module we've been estimating movie revenue based on movie budgets. 5
We were using a simple linear regression model that looked like this. 6
We had one explanatory variable which were the movie budgets and we were busy estimating the values 7
of these theta parameters, theta zero and theta one. When fitting more than one explanatory variable, more 8
than one feature, 9
the equation for the regression will look like this instead. This is the format of our model for our 10
multivariable regression. 11
Now, we don't have n different terms. 12
We've got 13 features in our data set and these are the ones we're going to use. 13
So in fact when we adapt this generic model to our specific circumstances, our equation will actually 14
look something like this. 15
The estimate of the price is equal to "theta0 + theta1 * RM", plus theta2 times our second 16
feature, plus theta3 times our third feature and so on until we get to our last one. 17
What this equation is telling us is that our estimate of the property price will be a linear combination 18
of these 13 features. 19
So it's still a linear model. 20
Okay. 21
So this is the model for our regression that we will be fitting our data to. 22
And when we run our Python code, we'll get a value for each of these theta parameters that we see here. 23
These are going to be our coefficients that we're interested in. 24
But before we write our code and run the numbers, did you ever wonder why this technique was called regression 25
in the first place? 26
Where does this name regression actually come from? I mean regression is such a strange word to be using 27
for fitting a line to our data. 28
Right? 29
So this technique and the name actually go back a long long time to an English gentleman called Francis 30
Galton, 31
Sir Francis Galton in fact. Sir Galton lived in Victorian England and had quite a few talents. 32
One of the many things he's remembered for today is his invention of the Galton board. 33
Yep. 34
He named this invention after himself. 35
Anyhow, a Galton board is basically what you end up with if you were to take his Japanese pachinko machine 36
and then extract all the fun out of it. 37
The Galton Board is a contraption that has a bunch of balls and pins in it. 38
When you turn this board upside down the balls go through a single opening at the top and then they 39
start bouncing off the pins. 40
And here's the fascinating part, what you end up with at the bottom of the board will look something 41
like a histogram from matplotlib. 42
In fact you get a very particular type of arrangement in the slots at the bottom. 43
And if you squint a little bit you'll actually recognise our old friend, the normal distribution. 44
Most of the balls end up in the middle but a very, very few balls bounce around like crazy on these pins 45
and they end up on the sides of the board. 46
They end up as outliers on the very, very left or on the very, very right hand edge. 47
Needless to say a lot of statisticians at the time were very excited about this invention. 48
But the thing is Sir Francis Galton was not a one trick pony. 49
No sir. 50
Being quite interested in both distributions and outliers, 51
he looked very, very, very carefully at the sizes of things, from the sizes of the seeds of his sweet peas 52
to the sizes of people. 53
In particular, he was very, very interested in how size changes from one generation to the next, especially 54
with regards to outliers. 55
Now one thing that Sir Galton noticed was that when you had a very, very tall father and that father 56
had a son and that son grew up to be an adult, the adult son was usually shorter than his father. 57
Sir Galton called this phenomenon Regression to the Mean. 58
That's where we get that word from, regression. Now you can even observe this phenomenon of the regression 59
to the mean in say like the NBA. Professional basketball players tend to be very very tall. 60
Right? 61
For example Shaquille O'Neal was 7 foot 1 or 216 centimeters. 62
At least that's what he's listed at on Wikipedia. 63
But what about the sons of an NBA player? Shaquille O'Neal son Sharif O'Neal is slightly shorter than 64
his father at two meters and eight centimeters or 6 foot 10. 65
Another example is actually Michael Jordan who was listed at 6 foot 6 and Michael Jordan's son Jeffrey 66
Jordan is listed at 6 foot 1. 67
Now I realize that those are just two examples and there aren't that many sons of basketball players in the 68
NBA whose height you can pull up on Wikipedia, but you'll find that this pattern holds on average the 69
NBA players sons will end up shorter than their dads on average. 70
This is regression to the mean in action.