Perceptron Learning Algorithm and Its Proof of Convergence
On this page 8 headings
Correct one mistaken prediction
Include the constant bias input. Start with weights [−1, 0], augmented input [1, 2], and true label 1. Predict 1 when the score is at least zero.
The current prediction is wrong.
For a missed positive point, add the input to the weights.
Check the same point after the correction.
What changed? The update changes a concrete mistaken decision. It does not guarantee that every other point is now correct.
Quick check: If this point had true label 0, would the original weights need an update?
No. The original score is negative, so its prediction of 0 would already be correct.
Swipe long formulas, tables or code sideways to see the rest.
Start here We don’t want to guess weights by hand. We want the perceptron to look at examples and fix itself whenever it makes a mistake. The Perceptron Learning Algorithm (PLA) does exactly that, using a simple rule: add the point if you wrongly said 0, subtract it if you wrongly said 1.
Lecture example — movie data We have m movies. For each movie we know whether the user liked it (1) or not (0). Each movie is described by n features, some 0/1 and some real: isActorDamon, isGenreThriller, isDirectorNolan, imdbRating (scaled ), …, x_{n} = criticsRating (scaled 0–1). We assume the data is linearly separable and want the perceptron to find the separating plane, i.e. find .
This is called binary classification: put each input into one of 2 classes.
P ← inputs with label 1
N ← inputs with label 0
Initialise w randomly
while not converged:
pick a random x from P ∪ N
if x ∈ P and wᵀx < 0: w = w + x
if x ∈ N and wᵀx ≥ 0: w = w − x
# converged = every input is classified correctlyHere (the dot product), with .
In words:
| Situation | Mistake | Fix |
|---|---|---|
| Positive point, but | said 0, should say 1 | |
| Negative point, but | said 1, should say 0 | |
| Correct answer | none | do nothing |
A little vector geometry. Write and .
The rule is now: if , else 0.
The boundary is the line . For any point x on this line, , so the angle α between w and x is 90°. Since w is at 90° to every point on the line, w is perpendicular to the line itself.
- Points with (positive side): angle with w is less than 90°.
- Points with (negative side): angle with w is more than 90°.
Case but (angle , we want ). New weight :
∝
is always positive, so . A bigger cosine means a smaller angle. w turns towards x. ✔
Case but (angle , we want ). New weight :
∝
bigger angle. w turns away from x. ✔
(Small note: the slides write “∝ ”. Strictly, it is that grows by ; the cosine also has in the denominator. The direction of the change is what matters, and the idea is right.)
Start with , go through the points in the order (0,0), (0,1), (1,0), (1,1), again and again. Each x is written as .
| # | Point | Label | Action | New w | |
|---|---|---|---|---|---|
| 1 | (0,0) | 0 | (≥ 0, wrong) | [−1, 0, 0] | |
| 2 | (0,1) | 1 | (< 0, wrong) | [0, 0, 1] | |
| 3 | (1,0) | 1 | none | [0, 0, 1] | |
| 4 | (1,1) | 1 | 1 (ok) | none | [0, 0, 1] |
| 5 | (0,0) | 0 | 0 (wrong) | [−1, 0, 1] | |
| 6 | (0,1) | 1 | 0 (ok) | none | [−1, 0, 1] |
| 7 | (1,0) | 1 | −1 (wrong) | [0, 1, 1] | |
| 8 | (1,1) | 1 | 2 (ok) | none | [0, 1, 1] |
| 9 | (0,0) | 0 | 0 (wrong) | [−1, 1, 1] | |
| 10–16 | rest of this pass, then one full pass | (0,0): −1, (0,1): 0, (1,0): 0, (1,1): 1 | none — all correct | [−1, 1, 1] |
Final: , i.e. fire when — exactly OR. Only 5 corrections were needed.
Lecture example — the toy run In the lecture’s animation, w starts pointing the wrong way (all positive points at more than 90°). Picking gives corrections; gives correction; and need nothing; gives one more . After that, a full pass over all points makes no change → the algorithm has converged.
Definition — absolutely linearly separable: sets P and N in n dimensions are absolutely linearly separable if there are numbers such that every point in P has and every point in N has .
Proposition: if P and N are finite and linearly separable, the PLA updates w only a finite number of times. (Test the points one after another in cycles; after finitely many steps, w separates the two sets.)
Setup tricks:
- , then −x behaves like a positive point ( ⇔ ). So make one set ( negated points of N). Now we only need for every , and only one “if” in the algorithm.
- Normalise every p so that . This does not change the answer (if then ).
- Let w* be a normalised solution. It exists because the data is separable — we just don’t know it.
Proof idea. be the angle between w* and the current w. Suppose by step t we have made k corrections . Look at
Numerator grows at least linearly. At a correction, , so , where over i of . Repeating for every correction: numerator .
Denominator grows slowly. (because we only correct when , and ). Repeating: .
Put together:
The top grows like k, the bottom only like . So the right side grows like and would become bigger than 1 for large k. But always. So k cannot keep growing — there is a maximum number of corrections, and the algorithm converges.
(The slide writes the denominator as ; it should be under a square root, since the denominator of is ‖w‖, not . The conclusion is the same.)
| Question | Answer |
|---|---|
| Non-Boolean (real) inputs? | Allowed in the perceptron ✔ |
| Must we hand-code the threshold? | No, it is learned as ✔ |
| Can some inputs matter more? | Yes, through weights ✔ |
| Functions that are not linearly separable? | Not possible with one perceptron ✘ → need a network (next page) |
In one line: PLA adds misclassified positive points to w and subtracts misclassified negative points; for linearly separable data it is guaranteed to stop after a finite number of corrections.
Exam words: binary classifier, Perceptron Learning Algorithm, convergence, dot product , angle between vectors, normalisation, absolutely linearly separable, ∪ , finite number of updates.
