ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Linear Algebra Essentials for Machine Learning
Chapter 1: Vectors in Machine Learning
Vectors as Data Representations
Fundamental Vector Operations
Vector Magnitude and Direction
The Dot Product and Projections
Vector Norms: Measuring Length
Calculating Distances Between Vectors
Implementing Vector Operations with NumPy
Hands-on Practical: Feature Vector Manipulation
Quiz for Chapter 1
Chapter 2: Matrices: Data Representation and Transformations
Matrices for Organizing Data
Basic Matrix Operations
Matrix Multiplication Explained
Matrices as Linear Transformations
Common Types of Matrices
Representing Systems of Linear Equations
Implementing Matrix Operations with NumPy
Hands-on Practical: Transforming Data Points
Quiz for Chapter 2
Chapter 3: Solving Linear Systems and Matrix Inverses
Linear Systems in Machine Learning Models
Introduction to Gaussian Elimination
The Matrix Inverse
Calculating the Inverse of a Matrix
The Determinant and Invertibility
Solving Ax=b using the Inverse
Numerical Stability and Alternatives
Hands-on Practical: Solving for Model Coefficients
Quiz for Chapter 3
Chapter 4: Vector Spaces, Subspaces, and Linear Independence
Defining Vector Spaces
Understanding Subspaces
Linear Combinations and Span
Linear Independence of Vectors
Basis and Dimension
Column Space and Null Space
Rank of a Matrix
Hands-on Practical: Analyzing Feature Vector Sets
Quiz for Chapter 4
Chapter 5: Eigenvalues and Eigenvectors
Definition of Eigenvalues and Eigenvectors
Geometric Interpretation
The Characteristic Equation
Calculating Eigenvectors
Eigen-decomposition of a Matrix
Significance in Principal Component Analysis (PCA)
Calculating Eigenvalues/Eigenvectors with NumPy
Hands-on Practical: Eigen-decomposition Calculations
Quiz for Chapter 5
Chapter 6: Matrix Decompositions for Machine Learning
Introduction to Matrix Decompositions
Singular Value Decomposition (SVD)
Geometric Interpretation of SVD
SVD for Dimensionality Reduction
SVD Applications in Data Compression
Relationship between SVD and Eigen-decomposition
Overview of LU Decomposition
Overview of QR Decomposition
Implementing Decompositions with SciPy/NumPy
Hands-on Practical: Applying SVD
Quiz for Chapter 6

Column Space and Null Space

The Column Space and Null Space are fundamental subspaces intrinsically linked to any given matrix AAA. These subspaces provide valuable understanding into the behavior of the linear transformation defined by AAA and the structure of the data it might represent. An understanding of the Column Space and Null Space is significant for analyzing linear models, feature relationships, and the solvability of linear systems. Vector spaces, span, and linear independence serve as foundational concepts for their definition and application.

The Column Space (Range)

For example, an m×nm \times nm×n matrix AAA with columns a1,a2,...,ana_1, a_2, ..., a_na1​,a2​,...,an​, which are vectors in RmR^mRm.

The Column Space of AAA, denoted as Col(A)Col(A)Col(A), is the set of all possible linear combinations of the columns of AAA. In other words, it's the span of the columns: Col(A)=span{a1,a2,...,an}Col(A) = \text{span}\{a_1, a_2, ..., a_n\}Col(A)=span{a1​,a2​,...,an​} Since the span of any set of vectors forms a subspace, Col(A)Col(A)Col(A) is a subspace of RmR^mRm.

What does the column space represent? Recall that the matrix-vector product AxAxAx can be written as a linear combination of the columns of AAA with weights given by the entries of xxx: Ax=x1a1+x2a2+...+xnanAx = x_1 a_1 + x_2 a_2 + ... + x_n a_nAx=x1​a1​+x2​a2​+...+xn​an​ This means that the column space Col(A)Col(A)Col(A) is precisely the set of all possible outputs bbb that can be achieved by the transformation x↦Axx \mapsto Axx↦Ax. If you think of AAA as defining a linear transformation T:Rn→RmT: R^n \to R^mT:Rn→Rm where T(x)=AxT(x) = AxT(x)=Ax, then Col(A)Col(A)Col(A) is the range of this transformation. It's the subspace in the output space RmR^mRm that the transformation can actually reach.

A system of linear equations Ax=bAx = bAx=b is consistent (i.e., has at least one solution) if and only if the vector bbb is in the column space of AAA. If bbb lies outside Col(A)Col(A)Col(A), then it's impossible to find weights x1,...,xnx_1, ..., x_nx1​,...,xn​ such that x1a1+...+xnan=bx_1 a_1 + ... + x_n a_n = bx1​a1​+...+xn​an​=b.

Finding a Basis for the Column Space A basis for the column space consists of a linearly independent set of columns that still span the entire column space. How do we find such a set? The pivot columns of the original matrix AAA form a basis for Col(A)Col(A)Col(A). To identify them, you typically row reduce AAA to its echelon form. The columns in the original matrix AAA that correspond to the pivot positions in the echelon form constitute a basis for Col(A)Col(A)Col(A).

The dimension of the column space, dim(Col(A))dim(Col(A))dim(Col(A)), is the number of vectors in its basis, which is equal to the number of pivot columns in AAA. This dimension has a special name: the rank of the matrix AAA. rank(A)=dim(Col(A))\text{rank}(A) = dim(Col(A))rank(A)=dim(Col(A)) The rank tells us the number of independent directions or dimensions spanned by the columns of AAA. In a machine learning context, if the columns represent features or transformed features, the rank indicates the effective dimensionality of that feature space. A rank less than the number of columns implies some linear dependence or redundancy among the features represented by the columns.

The Null Space (Kernel)

The Null Space of an m×nm \times nm×n matrix AAA, denoted as Nul(A)Nul(A)Nul(A), is the set of all vectors xxx in RnR^nRn that are mapped to the zero vector in RmR^mRm by the transformation x↦Axx \mapsto Axx↦Ax. Formally: Nul(A)={x∈Rn∣Ax=0}Nul(A) = \{x \in R^n \mid Ax = 0\}Nul(A)={x∈Rn∣Ax=0} The null space consists of all solutions to the homogeneous system of linear equations Ax=0Ax = 0Ax=0.

Is Nul(A)Nul(A)Nul(A) a subspace? Yes, it's a subspace of the input space RnR^nRn. We can verify this:

  1. The zero vector 0∈Rn0 \in R^n0∈Rn is always in Nul(A)Nul(A)Nul(A) because A0=0A0 = 0A0=0.
  2. If uuu and vvv are in Nul(A)Nul(A)Nul(A), then Au=0Au = 0Au=0 and Av=0Av = 0Av=0. Then A(u+v)=Au+Av=0+0=0A(u+v) = Au + Av = 0 + 0 = 0A(u+v)=Au+Av=0+0=0, so u+vu+vu+v is in Nul(A)Nul(A)Nul(A).
  3. If uuu is in Nul(A)Nul(A)Nul(A) and ccc is a scalar, then Au=0Au = 0Au=0. Then A(cu)=c(Au)=c(0)=0A(cu) = c(Au) = c(0) = 0A(cu)=c(Au)=c(0)=0, so cucucu is in Nul(A)Nul(A)Nul(A).

Geometrically, if AAA represents a transformation T:Rn→RmT: R^n \to R^mT:Rn→Rm, the null space Nul(A)Nul(A)Nul(A) is the set of all input vectors that get "squashed" or mapped onto the origin in the output space. This is also sometimes called the kernel of the transformation TTT.

Finding a Basis for the Null Space To find a basis for the null space, you need to find the general solution to the homogeneous equation Ax=0Ax=0Ax=0. This typically involves:

  1. Row reducing the augmented matrix [A∣0][A | 0][A∣0] to reduced row echelon form (RREF).
  2. Expressing the basic variables (corresponding to pivot columns) in terms of the free variables (corresponding to non-pivot columns).
  3. Writing the general solution vector xxx as a linear combination of vectors, where the weights are the free variables. The vectors in this linear combination form a basis for Nul(A)Nul(A)Nul(A).

The dimension of the null space, dim(Nul(A))dim(Nul(A))dim(Nul(A)), is the number of vectors in its basis, which is equal to the number of free variables in the system Ax=0Ax=0Ax=0. This dimension is often called the nullity of the matrix AAA. nullity(A)=dim(Nul(A))\text{nullity}(A) = dim(Nul(A))nullity(A)=dim(Nul(A))

If the nullity is greater than zero, it means there are non-zero input vectors that map to the zero vector. In terms of the system Ax=bAx=bAx=b, if a solution xpx_pxp​ exists (a particular solution), then any other solution can be written as x=xp+xhx = x_p + x_hx=xp​+xh​, where xhx_hxh​ is any vector from the null space (Axh=0Ax_h = 0Axh​=0). A non-trivial null space implies that solutions to Ax=bAx=bAx=b, if they exist, are not unique.

The Rank-Nullity Theorem

There's a fundamental relationship connecting the dimension of the column space (rank) and the dimension of the null space (nullity) for any m×nm \times nm×n matrix AAA. It's known as the Rank-Nullity Theorem: rank(A)+nullity(A)=n\text{rank}(A) + \text{nullity}(A) = nrank(A)+nullity(A)=n or dim(Col(A))+dim(Nul(A))=Number of columns of Adim(Col(A)) + dim(Nul(A)) = \text{Number of columns of } Adim(Col(A))+dim(Nul(A))=Number of columns of A

This theorem provides a powerful link between the input space (RnR^nRn) and the output space (RmR^mRm) of the transformation T(x)=AxT(x)=AxT(x)=Ax. It essentially states that the number of dimensions preserved by the transformation (the rank, dimension of the range) plus the number of dimensions collapsed to zero (the nullity, dimension of the kernel) must equal the total dimension of the input domain (nnn).

What does this imply:

  • If a matrix has a large null space (high nullity), many input dimensions are lost in the transformation, resulting in a lower-dimensional output space (low rank).
  • If a matrix has a trivial null space (nullity = 0, meaning only x=0x=0x=0 solves Ax=0Ax=0Ax=0), then no dimensions are lost, and the rank will be equal to the number of columns (nnn). This happens if and only if the columns of AAA are linearly independent.

Relevance in Data Analysis and Machine Learning

Why are these subspaces important in practice?

  • Column Space and Rank: The column space represents the space of all possible outcomes or predictions achievable by a linear model whose coefficients are determined by solving a system involving AAA. The rank of a feature matrix tells you the effective number of independent features. If the rank is less than the number of columns, it signals multicollinearity or redundant features, which can cause instability in some models (like linear regression). Dimensionality reduction techniques often aim to find a lower-rank approximation that captures most of the structure in Col(A)Col(A)Col(A).
  • Null Space: The null space identifies combinations of inputs (e.g., feature values) that have no effect on the output of the linear transformation AxAxAx. If Nul(A)Nul(A)Nul(A) contains non-zero vectors, it means different input combinations can lead to the same output. In solving systems like Ax=bAx=bAx=b, a non-trivial null space indicates infinitely many solutions if one exists. This relates to concepts like parameter identifiability in models. For instance, if the nullity of a design matrix in regression is greater than zero, the model coefficients are not uniquely determined.

By analyzing the column space, null space, and rank of matrices derived from datasets, we gain a deeper understanding of feature relationships, model capabilities, and potential issues like redundancy or non-uniqueness of solutions. These concepts form the foundation for more advanced techniques explored later, including matrix decompositions like SVD.

  • Introduction to Linear Algebra, Gilbert Strang, 2023 (Wellesley-Cambridge Press) - A widely used textbook for undergraduate linear algebra, providing detailed explanations of vector spaces, column space, and null space, which are foundational for understanding linear transformations.
  • Mathematics for Machine Learning, Marc Peter Deisenroth, A. Aldo Faisal, and Cheng Soon Ong, 2020 (Cambridge University Press) - Provides a targeted introduction to linear algebra concepts essential for machine learning, directly linking column and null spaces to data analysis and model characteristics.
  • 18.06SC Linear Algebra (Fall 2011), Gilbert Strang, 2011 (MIT OpenCourseWare) - Official course materials from MIT, offering video lectures and notes on column space, null space, and the fundamental theorem of linear algebra, accessible to a broad audience.

© 2026 ApX Machine Learning