When people say “vector,” most beginners think “array of numbers.” That intuition is wrong. A vector is an arrow in space: it has direction and length. Imagine standing in the center of a city. “Three blocks north and two east” is a vector. In ML, every object (customer, photo, word) becomes such an arrow in a high-dimensional feature space, and the model learns to tell these arrows apart.
Vectors: intuition and math
The norm of a vector is its “length.” But length can be measured in different ways. L2 (Euclidean) is the straight line from the tail to the tip: x2+y2. L1 (Manhattan) is moving on a grid, only along axes: ∣x∣+∣y∣. Click each metric below to see the difference visually.
The dot product a⋅b=a1b1+a2b2 measures how much two vectors point in the same direction. If the angle between them is small, the product is large and positive. If they are perpendicular — zero. If they point opposite ways — negative. Drag vector B with the mouse and watch how the result changes.
Each neuron does exactly one thing: it computes the dot product of the input vector with the weight vector. Then the activation decides whether the neuron “fires.” That's why understanding vectors isn't abstract math — it's the basis for how any neural network works.
import numpy as np
a = np.array([1.0, 2.0, 3.0])
b = np.array([4.0, 5.0, 6.0])
dot = np.dot(a, b) # 1*4 + 2*5 + 3*6 = 32
l2 = np.linalg.norm(a) # √14 ≈ 3.74
l1 = np.linalg.norm(a, ord=1) # 6.0
cos_sim = dot / (np.linalg.norm(a) * np.linalg.norm(b))