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

Understanding Subspaces

Vector spaces are fundamental structures in linear algebra. Within these spaces, important smaller, self-contained structures exist. Imagine the familiar 3D space, R3R^3R3. Inside this space, you can visualize planes and lines that pass through the origin. These aren't just arbitrary collections of points; they possess the same fundamental properties as the larger space they inhabit. These special subsets are called subspaces.

Formally, a subset WWW of a vector space VVV is called a subspace if WWW itself forms a vector space under the same addition and scalar multiplication operations defined on VVV. While checking all vector space axioms might seem tedious, there's a simpler test. A non-empty subset WWW of VVV is a subspace if and only if it satisfies three conditions:

  1. Contains the Zero Vector: The zero vector of VVV must also be in WWW. (0∈W0 \in W0∈W)
  2. Closure under Addition: For any two vectors uuu and vvv in WWW, their sum u+vu + vu+v must also be in WWW.
  3. Closure under Scalar Multiplication: For any vector uuu in WWW and any scalar ccc, the scalar multiple c⋅uc \cdot uc⋅u must also be in WWW.

Let's unpack these conditions with some geometric intuition.

Geometric Viewpoint: Lines and Planes Through the Origin

Think about R2R^2R2, the standard 2D Cartesian plane.

  • A line passing through the origin: For example, the set WWW of all vectors (x,y)(x, y)(x,y) such that y=2xy = 2xy=2x.
    • Does it contain the zero vector? Yes, (0,0)(0, 0)(0,0) satisfies 0=2×00 = 2 \times 00=2×0.
    • Is it closed under addition? Let u=(x1,2x1)u = (x_1, 2x_1)u=(x1​,2x1​) and v=(x2,2x2)v = (x_2, 2x_2)v=(x2​,2x2​) be two vectors on the line. Their sum is u+v=(x1+x2,2x1+2x2)=(x1+x2,2(x1+x2))u + v = (x_1 + x_2, 2x_1 + 2x_2) = (x_1 + x_2, 2(x_1 + x_2))u+v=(x1​+x2​,2x1​+2x2​)=(x1​+x2​,2(x1​+x2​)). This resulting vector also has its y-component equal to twice its x-component, so it lies on the line. WWW is closed under addition.
    • Is it closed under scalar multiplication? Let u=(x1,2x1)u = (x_1, 2x_1)u=(x1​,2x1​) be on the line and ccc be any scalar. Then c⋅u=(cx1,c(2x1))=(cx1,2(cx1))c \cdot u = (c x_1, c (2x_1)) = (c x_1, 2(c x_1))c⋅u=(cx1​,c(2x1​))=(cx1​,2(cx1​)). This vector also satisfies the condition y=2xy = 2xy=2x, so it's on the line. WWW is closed under scalar multiplication. Since all three conditions hold, the line y=2xy=2xy=2x is a subspace of R2R^2R2.

A line passing through the origin in R2R^2R2 satisfies the subspace conditions. It contains the origin, and adding any two vectors on the line or scaling a vector on the line results in another vector on the same line.

  • What about a line not passing through the origin? For example, the set W′W'W′ of vectors (x,y)(x, y)(x,y) such that y=2x+1y = 2x + 1y=2x+1. This set fails the first condition: the zero vector (0,0)(0, 0)(0,0) is not in W′W'W′ because 0≠2(0)+10 \neq 2(0) + 10=2(0)+1. Therefore, this line is not a subspace of R2R^2R2. The requirement that the zero vector must belong to any subspace is fundamental.

  • The entire space R2R^2R2 is also a subspace of itself. It trivially satisfies all conditions.

  • The set containing only the zero vector {0}\{0\}{0} is also a subspace. This is often called the trivial subspace.

Similarly, in R3R^3R3, lines and planes passing through the origin (0,0,0)(0, 0, 0)(0,0,0) are subspaces. A plane defined by ax+by+cz=0ax + by + cz = 0ax+by+cz=0 is a subspace, while a plane ax+by+cz=dax + by + cz = dax+by+cz=d (where d≠0d \neq 0d=0) is not, because it doesn't contain the origin.

Algebraic Example

For example, take the vector space V=R3V = R^3V=R3. Let WWW be the set of all vectors of the form (x,y,0)(x, y, 0)(x,y,0), where xxx and yyy are any real numbers. Geometrically, this represents the xy-plane within the 3D space. Let's rigorously check the conditions:

  1. Zero Vector: The zero vector in R3R^3R3 is (0,0,0)(0, 0, 0)(0,0,0). This fits the form (x,y,0)(x, y, 0)(x,y,0) with x=0x=0x=0 and y=0y=0y=0. So, the zero vector is in WWW.
  2. Closure under Addition: Let u=(x1,y1,0)u = (x_1, y_1, 0)u=(x1​,y1​,0) and v=(x2,y2,0)v = (x_2, y_2, 0)v=(x2​,y2​,0) be two arbitrary vectors in WWW. Their sum is u+v=(x1+x2,y1+y2,0+0)=(x1+x2,y1+y2,0)u + v = (x_1 + x_2, y_1 + y_2, 0 + 0) = (x_1 + x_2, y_1 + y_2, 0)u+v=(x1​+x2​,y1​+y2​,0+0)=(x1​+x2​,y1​+y2​,0). The result is still a vector with a zero in the third component, confirming that u+vu + vu+v is also in WWW.
  3. Closure under Scalar Multiplication: Let u=(x1,y1,0)u = (x_1, y_1, 0)u=(x1​,y1​,0) be in WWW and ccc be any scalar (a real number). Then c⋅u=(cx1,cy1,c⋅0)=(cx1,cy1,0)c \cdot u = (c x_1, c y_1, c \cdot 0) = (c x_1, c y_1, 0)c⋅u=(cx1​,cy1​,c⋅0)=(cx1​,cy1​,0). This resulting vector also has a zero in the third component, so c⋅uc \cdot uc⋅u is in WWW.

Since all three conditions are met, the set WWW (the xy-plane) is indeed a subspace of R3R^3R3.

Why Subspaces Matter in Machine Learning

Understanding subspaces is not just a theoretical exercise; it provides valuable insights into data structure and algorithm behavior:

  • Feature Subspaces: Imagine your dataset has many features (e.g., hundreds of measurements for each data point), meaning your data vectors live in a high-dimensional space RnR^nRn. If you perform feature selection or feature engineering, you might choose to work with a smaller set of features. The data, when represented using only this subset of features, effectively resides within a subspace of the original feature space. The properties of this subspace, such as its dimension (which we'll discuss soon), relate directly to the complexity and redundancy of the selected features. For instance, Principal Component Analysis (PCA) explicitly seeks a lower-dimensional subspace that captures most of the variance in the data.
  • Solution Spaces: When solving systems of linear equations, particularly homogeneous systems of the form Ax=0Ax = 0Ax=0, the set of all possible solution vectors xxx forms a subspace. This is known as the null space (or kernel) of the matrix AAA. Understanding this subspace is important for analyzing the uniqueness of solutions to linear systems that arise in model fitting, like in linear regression.
  • Manifold Hypothesis: While often dealing with non-linear structures, the manifold hypothesis in machine learning suggests that complex, high-dimensional data (like images or natural language embeddings) often lies concentrated near a lower-dimensional manifold embedded within the higher-dimensional ambient space. Although manifolds are generally curved, their local structure can sometimes be approximated by flat subspaces (tangent spaces). Subspaces provide the essential linear algebraic foundation for thinking about data that exhibits lower-dimensional structure, even if that structure isn't perfectly flat globally.

Identifying whether a given set of vectors forms a subspace involves verifying the three closure properties. If any one property fails (e.g., the set doesn't contain the zero vector, or adding two vectors in the set gives a vector outside the set), then it is not a subspace. This systematic check helps us categorize and analyze structured subsets within larger vector spaces, which is fundamental for understanding data transformations, dimensionality reduction techniques, and the behavior of various machine learning models.

  • Introduction to Linear Algebra, Gilbert Strang, 2016 (Wellesley-Cambridge Press) - Classic textbook providing a thorough treatment of vector spaces and subspaces, with strong geometric intuition and applications.
  • Linear Algebra and Its Applications, David C. Lay, Steven R. Lay, Judi J. McDonald, 2021 (Pearson) - Widely-used textbook that clearly explains subspaces with numerous examples and a focus on practical applications.
  • Mathematics for Machine Learning, Marc Peter Deisenroth, A. Aldo Faisal, Cheng Soon Ong, 2020 (Cambridge University Press) - Provides a focused introduction to linear algebra concepts, including subspaces, as they relate to machine learning algorithms and data analysis.
  • 18.06SC Linear Algebra, Gilbert Strang, 2011 MIT OpenCourseWare (Massachusetts Institute of Technology) - MIT's free online course, featuring lectures and materials that thoroughly cover vector spaces and the properties of subspaces.

© 2026 ApX Machine Learning