ML Notes Mathematics Fundamentals

Matrix Fundamentals

A practical guide to matrix basics for machine learning: shapes, multiplication, geometry, determinants, rank, and invertibility.

Contents

What Is a Matrix?


Matrix Operations

Addition and Scalar Multiplication

αA=[αaij]\alpha A = [\alpha a_{ij}]

Matrix Multiplication

AB∈Rm×pAB \in \mathbb{R}^{m \times p} (AB)ij=∑k=1nAikBkj(AB)_{ij} = \sum_{k=1}^{n} A_{ik}B_{kj} AB≠BAAB \ne BA

Transpose

Aij⊤=AjiA^\top_{ij} = A_{ji} (AB)⊤=B⊤A⊤(AB)^\top = B^\top A^\top

Geometry of Matrices

Matrix as a Linear Transformation

Column-Space View

Dot Product and Orthogonality

x⊤y=∑ixiyix^\top y = \sum_i x_i y_i

Determinant

Meaning

Key Facts

For a 2×22 \times 2 matrix:

A=[abcd],det⁡(A)=ad−bcA=\begin{bmatrix}a & b \\ c & d\end{bmatrix},\quad \det(A)=ad-bc

Invertibility

Inverse Matrix

A−1A=AA−1=IA^{-1}A = AA^{-1} = I

Equivalent Conditions

For square AA, these are equivalent:


Rank and Linear Independence


Systems of Linear Equations

Ax=bAx=b

Matrices in Machine Learning

y^=Xw+b\hat y = Xw + b w=(X⊤X)−1X⊤yw = (X^\top X)^{-1}X^\top y Σ=1mX⊤X\Sigma = \frac{1}{m}X^\top X

Practical Notes

Check shapes before multiplying.

Avoid explicit matrix inverse when solving systems.

Standardise features for distance-based and regularised methods.


Why This Matters for ML

← Back to Blog