Matrices Hold and Transform Vectors

A table of numbers with algebraic structure

A matrix is a rectangular grid of numbers. In tabular ML, rows commonly represent observations and columns represent features. Matrix multiplication combines inputs with weights in a precise pattern, which lets one operation calculate many model outputs efficiently.

X (3 rows x 2 features)      w (2 weights)
[1  10]                      [0.5]
[2  20]          times       [0.1]
[3  30]

result: [1.5, 3.0, 4.5]

A matrix can also represent a linear transformation: a rule that scales, rotates, or combines vector directions without curving space. Neural-network layers repeatedly multiply inputs by weight matrices, add biases, and then apply nonlinear activation functions. Understanding the grid and shape is more important here than memorizing hand calculations.

Warning: Matrix dimensions must align. If X has 2 feature columns, the weight vector needs 2 corresponding entries. A dimension error is often a data-contract error in disguise.
Tip: Write shapes beside each object while debugging: X:(1000, 8), w:(8,), prediction:(1000,). Shape annotations catch many conceptual mistakes early.