Lensa ML
Lensa ML

How Linear Algebra Powers ML

Step 1 of 6

What's a Vector?

Numbers with direction — the building blocks of data

xy[3.0, 2.0]
3.0
2.0
Magnitude
3.61
Direction
33.7°

A vector is just a list of numbers — here, two numbers [x, y] that define an arrow. The arrow has a magnitude (length) and a direction (angle). Drag the sliders to see how changing the components changes the arrow.

Step 1 of 6: What's a Vector?

Numbers with direction — the building blocks of data

xy[3.0, 2.0]
3.0
2.0
Magnitude
3.61
Direction
33.7°

A vector is just a list of numbers — here, two numbers [x, y] that define an arrow. The arrow has a magnitude (length) and a direction (angle). Drag the sliders to see how changing the components changes the arrow.

Step 2 of 6: Vectors as Data

Every data point is a vector in disguise

NameHeightWeightAlice16558Bob18082Carol15552Dave17575Eve16063HeightWeight

Every row in a dataset is a vector in disguise. A person with height 165 and weight 58 is just the point [165, 58] in 2D space. Click a row or a point to see the connection.

Step 3 of 6: The Dot Product

Measuring similarity between vectors

a[1.00, 0.00]b[0.87, 0.50]DOT PRODUCT0.866
OPPOSITEORTHOGONALSIMILAR

The dot product measures how much two vectors point in the same direction. When vectors are aligned (0°), it's maximum. At 90°, it's zero — the vectors are unrelated. At 180°, they point in opposite directions.

Step 4 of 6: What's a Matrix?

A grid of numbers that transforms data

MATRIX1.0 0.00.0 1.0
a1.0
b0.0
c0.0
d1.0

A matrix is a grid of numbers that transforms space. The dashed square is the original; the solid shape is after transformation. Try the presets to see rotation, scaling, and shearing in action.

Step 5 of 6: Matrix Multiplication

Combining transformations step by step

A (2×3)123456×B (3×2)789101112=C (2×2)58???1×7 + 2×9 + 3×11 = 58← PrevNext →▶ AutoCell [1,1] of 4

Matrix multiplication computes each output cell as a dot product of a row from A and a column from B. Step through each cell or hit Auto to watch the whole multiplication unfold.

Step 6 of 6: Why It Matters for ML

Layers are just matrix multiplications

INPUTvector0.8x10.3x2WEIGHT MATRIX[ 0.6, -0.2][ 0.3, 0.8][-0.5, 0.4]OUTPUTσ(W·x)y = σ(W · x)
0.80
0.30

A neural network layer is just a matrix multiplication followed by an activation function. The input vector is multiplied by a weight matrix to produce the output. Every layer in every neural network works exactly like this — linear algebra is the engine of ML.