Skip to main content
Luxara Academy

Archive — one question answered

Why must data be vectorized?

You cannot feed raw email text into a net — how do you turn it into numbers?

A neural net only accepts fixed-length numbers, not variable-length raw text. In the course spam inbox, each email becomes three counts: promotional words, links, unknown sender. Email A is (2,0,1)(2, 0, 1), email B is (0,1,1)(0, 1, 1) — same dimension d=3d = 3.

Storing only the string "50% off today" leaves every message a different length, so there is no shared matrix multiply. Vectorization picks a feature dictionary and counts in a fixed order. Permuting columns changes meaning: (2,0,1)(2,0,1) is not (0,2,1)(0,2,1).

Python on four tiny emails:

python
counts = [(2, 0, 1), (0, 1, 1), (5, 2, 1), (0, 0, 0)]
assert all(len(x) == 3 for x in counts)

During batch training, NumPy stacks an XX matrix of shape (batch, 3) and multiplies once by W\mathbf{W}. That is why deep learning courses start with vectorization: it is the prerequisite for GPUs and gradient descent at scale. The spam filter project in the course never sees raw email bodies in the training loop — only these fixed-length vectors.