Maths · Module 2
Vectors
Take each lesson, answer its quiz, then do its practice. After the last lesson come the module quiz, the project and the interview questions.
Lessons
- 2.1VectorsSee a row of data as a point and as an arrow, in any number of dimensions.
- 2.2Vector Arithmetic and NormsAdd, scale and measure vectors, and know that "length" has more than one definition.
- 2.3The Dot Product, Angle and ProjectionCompute a dot product and read it as alignment, and project one vector onto another.
- 2.4Lines, Planes and HyperplanesRead `wᵀx + b = 0` as a boundary in any dimension: which side a point is on, and how far away it is.
- 2.5Shapes and Distance in d DimensionsWrite the shapes that appear as decision regions and constraints, and see why distance behaves differently as the dimension grows.
Module material
Take these after the last lesson, in this order. Next on each page leads through them.
- Module quiz15 questions across the whole module. Take it after the last lesson; your first pick on each question is the one that counts.
- PracticeStated as a problem, with no template and no step-by-step instructions. Working out the steps is the point.
- NotebooksOpen them in Google Colab. Each answer is checked as you go: correct, wrong with the expected value, or not answered yet.
- Cheat sheetOne page of the module’s terms, rules and gotchas, with the output each rule produces.
- Interview questions14 questions interviewers ask on this module’s topics, from first principles to the follow-ups. Each comes with a model answer.
Glossary
Every term the module introduces, with the lesson that introduces it.
- origin
- the point
(0, 0)| where the axes cross 2.1 - component
- one entry of a vector |
3in(3, 2)2.1 - vector
- an ordered list of numbers; drawn as a point or an arrow from the origin |
(3, 2)2.1 - dimension
- the number of components |
(3, 2, 4)is in three 2.1 - row vector
- one row,
1 × d|u.reshape(1, -1)2.1 - column vector
- one column,
d × 1|u.reshape(-1, 1)2.1 - point cloud
- a table drawn as one point per row | the ward's 14 patients 2.1
- feature space
- one axis per feature | white-cell count against temperature 2.1
- vector addition
- add matching components; head to tail |
(3, 1) + (1, 2) = (4, 3)2.2 - scalar multiplication
- every component times one number |
2 · (3, 1) = (6, 2)2.2 - mean vector (centroid)
- the component-by-component mean of a set of points |
(4, 3)2.2 - norm
- a length of a vector | 2.2
- L2 (Euclidean) norm
√(Σ vᵢ²), the straight-line length |5for(3, −4)2.2- L1 (Manhattan) norm
Σ \ | vᵢ\ ||72.2- L∞ (max) norm
max \ | vᵢ\ ||42.2- distance
- the norm of the difference,
‖a − b‖|2.2361from(3, 1)to(1, 2)2.2 - unit ball
- every point with norm at most one | circle, diamond, square 2.2
- standardising
- subtract the mean, divide by the standard deviation | the lot's age and mileage 2.2
- z score
- a value in standard deviations from the mean | car 25's age,
−0.192.2 - penalty
- a norm of the weights added to a model's error | ridge:
‖w‖₂²; lasso:‖w‖₁2.2 - dot product
- the sum of the products of matching components |
(3, 4) · (2, 1) = 102.3 - orthogonal
- perpendicular; dot product zero |
(3, 4)and(0.8, −0.6)2.3 - cosine
- the horizontal coordinate of the point at angle θ on the unit circle |
cos 60° = 0.52.3 - angle between vectors
cos θ = a · b / (‖a‖ ‖b‖)|26.57°2.3- unit vector
- a vector of length one,
a / ‖a‖|(0.6, 0.8)2.3 - projection
- the part of a vector along a direction,
(b · â) â|(1.2, 1.6)2.3 - count vector
- one component per vocabulary word | email 12,
(2, 0, 1, 1, 1, 0, 0, 0, 0, 0)2.3 - cosine similarity
- the cosine of the angle between two vectors |
0.5714for emails 12 and 13 2.3 - score
w · x + bfor a pointx|6forP = (4, 3)2.4- normal vector
- a vector perpendicular to a line or plane; here
w|(1, 2)2.4 - offset (bias)
b, which moves the line without turning it |−42.4- half-space
- all the points on one side of a line or plane | the positive side 2.4
- signed distance
(w · x + b) / ‖w‖, positive on the sidewpoints to |2.68332.4- plane
w · x + b = 0in three dimensions |x + 2y + 2z − 6 = 02.4- hyperplane
- the points where
w · x + b = 0, in any dimension | 2.4 - linear classifier
- predicts the class from the sign of
w · x + b| the ward line, 14 of 14 2.4 - hypersphere
- every point at distance
rfrom a centre, inddimensions |‖x − c‖₂ = r2.5 - ball
- every point within distance
rof a centre |‖x − c‖₂ ≤ r2.5 - hypercube
- every component inside the same interval | the unit cube
[0, 1]ᵈ2.5 - axis-parallel box
- one interval per feature; the region a tree's splits describe |
12of 14 on the ward 2.5 - distance concentration (curse of dimensionality)
- in high dimensions, the nearest and farthest neighbours are almost equally far away | ratio
1.123atd = 10002.5