Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 9

Matrix Rank and Data Dimensionality

Recommended resources

In our last two lessons, we explored two fundamental properties of matrices. First, we examined linear independence, which tells us about redundancy in the input features. Then, we defined the column space, which represents the complete set of all possible outputs of a transformation. Today, we will unite these two ideas to define and understand the rank of a matrix.

This lesson addresses a core concept in linear algebra that has profound implications for machine learning. You will learn to compute the rank of a matrix and, more importantly, to interpret it as the effective dimensionality of the data it represents. This will give us a precise tool to measure the amount of unique, non-redundant information contained within a dataset, a crucial step in building robust and interpretable models.

From Column Space to Rank

In the previous lesson, you saw how a linear transformation can squish space into a lower-dimensional subspace. For example, a 3D transformation might map all vectors onto a plane or a line. The set of all possible outputs—that plane or line—is the column space.

The rank of a matrix is simply the number of dimensions of its column space.

  • If a transformation squishes 3D space onto a plane, its output is 2-dimensional. The rank is 2.
  • If it squishes 3D space onto a line, its output is 1-dimensional. The rank is 1.
  • If it leaves the space as 3D (non-zero determinant), its output is 3-dimensional. The rank is 3.

This concept was visualized in the 3Blue1Brown video from our last session. To refresh your memory, take a moment to re-watch the key segment where rank is introduced.

Inverse matrices, column space and null space | Chapter 7, Essence of linear algebra

This clip from "Inverse matrices, column space and null space" by 3Blue1Brown provides the core geometric intuition for rank.

Watch the section from 08:06 to 09:28. Focus on how the narrator defines rank as the number of dimensions in the output of a transformation and connects it directly to the column space.

The video provides the crucial link: the rank of a matrix is the dimension of its column space. Because the column space is the span of the matrix's columns, the rank is also equal to the number of linearly independent columns in the matrix. This gives us a more practical way to think about and compute rank. It tells us how many of our feature vectors are truly unique and not just combinations of other features.

This image illustrates the core idea perfectly. The data points are plotted in a 3D space (3 features), but they all lie on a 2D plane. The apparent dimension of the data is 3, but its intrinsic dimension, or rank, is 2. This happens because one feature is redundant—it's a linear combination of the other two.

Rank as Informational Dimension

Thinking of rank as the number of linearly independent columns reveals its true importance in machine learning: it measures the "informational dimension" of your data. If your 1000-feature dataset has a rank of 50, it means that all the information in those 1000 features can actually be expressed using just 50 "ingredient" features. The other 950 are redundant.

This has a powerful, practical application in data compression. The following video offers a fantastic, algorithm-focused explanation of how to compute rank and why it's useful for compressing data.

Rank of a Matrix : Data Science Basics

The video "Rank of a Matrix : Data Science Basics" by ritvikmath explains rank from a data scientist's perspective.

First, watch the segment on computing rank. The method presented—going column by column and asking if it's a linear combination of the previous ones—is a very intuitive, algorithmic way to understand linear independence and rank. Next, watch the segment on data compression. This is the key application. Pay close attention to how a matrix A can be decomposed into a smaller "ingredients" matrix and a "recipes" matrix, and how the rank k determines the size of this decomposition and the resulting compression ratio.

As the video demonstrates, if a matrix A (size ) has a rank k, it can be decomposed as a product of two smaller matrices: an "ingredients" matrix and a "recipes" matrix. Instead of storing numbers, you only need to store numbers. For a large dataset where the rank k is much smaller than the number of features p, this is a massive saving.

For your project on differentiating ALL from AML, imagine your data matrix has thousands of genes (features). If this matrix has a low rank, it implies that the expression patterns are highly structured. Perhaps large groups of genes are co-regulated, acting as a single "biological signal." Finding the rank tells you how many of these independent signals exist in your data.

This image reinforces the connection between rank, linear independence, and span. If `col_3` is simply a multiple of `col_1`, it adds no new direction to the data's span. It's redundant, and the rank is lower than the number of columns.

From Theoretical Rank to "Effective" Rank

The idea of perfect linear dependence and exact rank works well for clean, theoretical examples. However, real-world data is noisy. In your gene expression data, it's unlikely that gene_C_expression = 2 * gene_A_expression exactly. It's more likely to be gene_C_expression = 2 * gene_A_expression + biological_noise.

In this scenario, the columns are no longer perfectly linearly dependent, so the theoretical rank would be full. Yet, the data is almost lower-dimensional. This is where the concept of effective rank becomes essential. It provides a more practical, continuous measure of dimensionality for noisy data.

The following article gives a superb introduction to this concept, using the context of financial asset correlations, but the principle is identical for biological data.

The Matrix Effective Rank: Measuring the Dimensionality of a Universe of Assets | Portfolio Optimizer

This article from Portfolio Optimizer explains the need for and definition of effective rank.

Read the article from the beginning down to the end of the "Main properties" section. Focus on: The introductory examples of three correlation matrices. Notice how C₃ has a rank of 3, but intuitively feels like it represents only 1 asset because of the high correlations. This highlights the limitation of theoretical rank. The section on "Interpretation." It has excellent visualizations showing how the columns of a high-rank matrix can be so close together that they almost span a lower-dimensional space. The formal definition, which uses the eigenvalues of the matrix. We will cover eigenvalues in depth later, but for now, understand that they measure the variance along different directions in the data. Effective rank essentially counts how many "significant" directions of variance there are. Property 1, which states that effective rank is always less than or equal to the theoretical rank.

The article also makes a fascinating connection to your field: the formula for effective rank is the same as for a biodiversity metric called the Hill number. This shows how the same mathematical concept of measuring "effective diversity" appears in both finance and biology.


Rank in the Context of Biological Data Analysis

The concept of rank, and especially its connection to the Singular Value Decomposition (SVD) and Principal Component Analysis (PCA), is a cornerstone of modern computational biology. Let's look at how it's framed in a textbook dedicated to this field.

7 Multivariate Analysis – Modern Statistics for Modern Biology

This chapter explains rank from a generative perspective and shows its application in a biological context.

Start with the subsection "Rank-one matrices." This gives a beautiful generative model for rank, showing how a rank-1 matrix is formed from the outer product of two vectors. This reinforces the "ingredients" and "recipes" idea. Skim the next subsection, "How do we find such a decomposition...". The key takeaway here is that SVD can decompose any matrix into a sum of rank-1 matrices, and the number of non-zero singular values tells you the rank. Notice how for the Xtwo matrix, the third and fourth singular values are nearly zero, indicating an effective rank of 2. Finally, read the section "PCA of the turtles data." Look at the screeplot (Figure 7.17). It shows the magnitude of variance (related to eigenvalues) for each principal component. The first component is huge, while the other two are tiny. This is a visual representation of effective rank. The data is technically 3-dimensional, but it is effectively 1-dimensional. This is exactly what you would do with your cancer data: create a screeplot to determine its "true" informational dimension.


Conclusion

In this lesson, we have given a precise meaning to the "true dimensionality" of data. We've seen that rank is a powerful concept that unifies the ideas of linear independence and the output space of a transformation.

Key Takeaways:

  • Rank is the dimension of the column space, which is equal to the number of linearly independent columns of a matrix.
  • It measures the informational dimensionality of your data, telling you how many unique features are present.
  • Low-rank matrices contain redundant information and can be compressed by decomposing them into smaller "ingredient" and "recipe" matrices.
  • For noisy, real-world data, effective rank provides a more robust, continuous measure of dimensionality by quantifying how close the data is to lying in a lower-dimensional subspace.
  • Techniques like PCA and SVD, visualized through screeplots, are the primary tools used in ML and computational biology to estimate the effective rank of a dataset.

Now that we have a solid understanding of a matrix's properties from both the input side (linear independence) and output side (column space and rank), we are equipped to tackle one of the central questions in linear algebra: solving the equation . In the next lesson, we will synthesize these concepts to determine when a model has a solution, whether that solution is unique, and what this means for fitting models to data.