Understand the relationship between linear algebrea and linear models.
Recall that while building a linear regression models, we generally have an outcome variable y, which we want to predict using a set of predictor variables X. For example, y could refer to the number of ice creams sold, and X could refer to the temperature.
In linear algebra notation, y is then a column vector of variables.
Y = [[y1, y2, y3, …, yN]]
And in the case of a simple linear regression, x is a column vector similar in shape to y.
x = [[x1, x2, x3, …, xN]]
In the case of multiple linear regression, X is now a matrix of predictor variables. Assuming we have N rows of K variables:
X = [[x1,1, x1,2, x1,3, …, x1,K], [x2,1, x2,2, x2,3, …, x2,K], …, [xN,1, xN,2, xN,3, …, xN,K]]
We cam now write down our linear regression model as
y = beta
.X
Where:
beta
is a vector of regression coefficients
error
is the irreducible error
Recall from the previous lesson that linear systems can be represented in linear algebra form as:
Ax = b
Since we have now represented our linear regression model as a linear system, we can solve it using tools of linear algebra.
The solution to the linear regression problem we stated as
y = beta
.X
is given by
beta_hat
= (XTX)-1.XTy
Proving the normal equations requires mathematical tools that will be introduced in Year 2. We will re-visit the normal equations then :).
Tomorrow in the data lab, we will implement the normal equations and learn how they work in practice.
Today's takeaway is that the normal equations are beautiful and a direct application of linear algebra concepts to machine learning!
Linear Algebra
course in Code Academy which can be found here and upload a certificate of completion to your learning logs.OR
Matrices
course in Khan Academy which can be found here and upload evidence of completion to your learning logs.