Vectors
Lists with direction.
In machine learning, everything becomes a list of numbers. A house is its size, rooms, and age. An image is its pixel values. A word can be three hundred numbers. A list of numbers like that is called a vector.

- Everything becomes numbers
- A house, an image, a word
- A vector
Vectors in NumPy
A vector is just a one dimensional NumPy array. This house is a hundred and twenty square metres, with four rooms, and ten years old. Its shape is three, so it lives in three dimensional space. Each position always means the same feature. Run it.
import numpy as np
house = np.array([120, 4, 10])
print(house)
print("shape:", house.shape)
print("rooms:", house[1])[120 4 10] shape: (3,) rooms: 4
Two ways to picture a vector
You can think of a vector as a point in space, like a dot on a map at position three, two. Or as an arrow from the origin to that point, with a length and a direction. Both pictures are useful. With three hundred numbers we can't draw it, but the same maths still works.
| key | value |
|---|---|
| Vector | an ordered list of numbers |
| As a point | a position in space |
| As an arrow | length and direction |
| Dimensions | how many numbers |
Summary
A vector is an ordered list of numbers, a point or an arrow in space. Every data row is a vector. Next, adding and scaling vectors.
Key takeaways- np.array([...])
- shape = dimensions
- Point or arrow