3.2 Linear Dependence, Independence, and Matrix Rank
In machine learning, we feed datasets containing many features (variables) into our algorithms. But what if some of these features are redundant? What if two features tell us the exact same thing?
In this lecture, we will study Linear Independence and Matrix Rank—two critical diagnostic tools that help us detect hidden redundancies in our data matrices.
1. Linear Combinations & Span
Before we can define independence, we must understand how vectors combine to cover space.
Linear Combinations
A linear combination of a set of vectors is a new vector obtained by scaling each vector and adding them together:
- Example: Let and . If we choose scalars and :
The Span
The Span of a set of vectors is the set of all possible linear combinations you can create from them. Geometrically:
- Span of one vector: A 1D line passing through the origin.
- Span of two vectors in 3D: If they don't point in the same direction, they span a 2D flat plane.
- Span of three vectors in 3D: If they don't lie in the same plane, they span the entire 3D space.
2. Linear Independence vs. Dependence
How do we know if a new vector adds a "new direction" to our span, or if it is redundant?
Linear Independence
A set of vectors is linearly independent if no vector in the set can be written as a combination of the others. Every vector provides completely new, unique spatial information.
Mathematically, the equation: has only the trivial solution .
Linear Dependence
If at least one vector in the set can be written as a linear combination of the others, the set is linearly dependent. Adding a dependent vector to our set does not expand the Span.
- Example: If , , and . Here, . The vector lies along the same line as . It adds no new direction, so the set is dependent.
Linearly Independent Linearly Dependent
(Vectors point in new directions) (One vector is redundant)
▲ ▲
│ v2 │ v2
│ │ ╱
┼─────► ┼─╱───►
v1 v1 v3 (redundant)
3. Machine Learning Connection: Multicollinearity
In statistics and machine learning, linear dependence in a feature matrix is called Multicollinearity.
Imagine you are predicting house prices using features:
- : Area in square feet.
- : Area in square meters ().
- : Number of bedrooms.
Because is a direct linear combination of , their columns in the data matrix are linearly dependent.
If you feed this matrix into a linear regression model, the covariance matrix becomes singular (non-invertible), causing the training algorithm to crash or output wildly unstable, meaningless weights! We must drop one of the redundant features to make the columns independent.
4. Matrix Rank
The Rank of a matrix is the total number of linearly independent rows or columns in that matrix. It tells us the actual dimension of the space spanned by the matrix.
How to Calculate Rank using RREF
To find the rank of a matrix:
- Perform Gaussian elimination to convert the matrix into Reduced Row Echelon Form (RREF).
- Count the number of pivots (non-zero rows). This count is exactly the Rank of the matrix!
- Example: Let's look at matrix :
- Notice that the second row is just (it is dependent).
- If we perform row operations to get RREF, the second row collapses to all zeros:
- There are only 2 pivots (non-zero rows). Therefore, Rank(A) = 2. Even though is a matrix, it only contains 2 dimensions of unique information.
Full Rank vs. Rank Deficient
- Full Rank: An square matrix is Full Rank if its rank is exactly . This means all rows/columns are independent, and the system is fully solvable.
- Rank Deficient: If its rank is less than (Rank ), the matrix is singular and cannot be inverted.