2.1 Introduction to Linear Systems
Now that we understand vectors, we can scale up to look at systems of multiple equations. In machine learning, we are almost always dealing with relationships between variables. The simplest relationship is a linear relationship.
In this lecture, we will learn what a linear system of equations is, how to solve small systems manually, and why this is the foundational concept behind one of the oldest and most widely used machine learning algorithms: Linear Regression.
1. What is a Linear System?
A system of linear equations is a collection of two or more linear equations sharing the same set of unknown variables.
- Example (2 Equations with 2 Unknowns):
To "solve" this system means to find a pair of values that satisfies both equations at the same time. Let's solve this small system:
- From the second equation, we can express in terms of :
- Substitute this expression into the first equation:
- Now substitute back to find :
So, the unique solution is and . Geometrically, if you draw these two equations as lines on a 2D grid, they will intersect at exactly the coordinate .
2. Machine Learning Motivation: Linear Regression
How does this connect to AI and Machine Learning?
Imagine you are trying to predict electricity production () of a wind turbine based on wind speed (). You collect historical data, and you assume the relationship is a straight line:
- (Weight / Slope): How much electricity increases per unit of wind speed.
- (Bias / Intercept): The baseline electricity produced when there is no wind.
Here, the unknowns we need to find are and .
Suppose we observe two data points:
- At wind speed , electricity produced is .
- At wind speed , electricity produced is .
We can plug these observations into our model to create a system of two linear equations:
If we solve this system:
- Subtract the first equation from the second:
- Substitute back into the first equation:
So our predictive model is: .
3. Hands-on Experiment
In real life, we don't just have 2 data points; we have hundreds or thousands! We cannot draw a single straight line that passes through all of them perfectly. Instead, we try to find the "best fitting line" that gets as close as possible to all data points.
Use the interactive chart below to manually adjust the Slope () and Intercept () to fit the scattered data points.