Perceptron
Also Perceptron Algorithm
An iterative algorithm that learns a linear classifier (w, b) by going over the training points in rounds and, for every misclassified point x with label y ∈ {+1, −1}, updating w ← w + y·x and b ← b − y.
Know these firstLinear Classifier
Properties#
- Boundary points are always updated ( counts as wrong), in the direction that moves the prediction towards the correct side (exam WS 15/16, Task 4). Without this rule the start would never change.
- Effect of one update: after , : , so the score of moves by towards the correct sign (it may need several updates to cross).
- Label symmetry: swapping all labels yields exactly after every step. Proof by induction over the steps: if , , then the swapped condition equals the original , and the updates give , (exam WS 15/16, Task 4.3).
- Result depends on the order of the training points and on the number of rounds; the final hyperplane is some separating one, not a particular “best” one.
Example#
def perceptron():
w, b = 0, 0
for _ in range(50):
for x in range(1, 9):
y = 1 if x >= 5 else -1
if y * (w * x - b) <= 0:
w, b = w + y * x, b - y
return w, b
Sources#
- Not covered by a WS 25/26 lecture. Source: the former Information Retrieval exams.
- Exam WS 15/16, Task 4 (not published) (one round, implementation, label symmetry)