Playground / Perceptron (Batch)

Train a Perceptron on your points

Perceptron (Batch)

Interactive lab

Try it: Perceptron (Batch)

How the Batch Perceptron learns a halfspace: it looks for an example with y⟨w,x⟩ ≤ 0 and adds y·x to w, until no mistakes remain — which happens only when the data is linearly separable.

How it works

  1. Start with w = 0 (with a bias, each x is extended with a constant 1, so b is learned as a weight).
  2. Scan the examples in order and take the first one with y⟨w,x⟩ ≤ 0 — a mistake.
  3. Update w ← w + y·x; the separating line ⟨w,x⟩ + b = 0 moves towards classifying it correctly.
  4. Repeat until a full pass finds no mistake (converged) or the update cap is reached.
  5. If the data is not linearly separable (checked exactly), no w works and the Perceptron would cycle forever.

Default run (14 steps): Start with w = 0 (and b = 0: x is extended with a constant 1). Every example has y⟨w,x⟩ = 0 ≤ 0, so every one counts as a mistake. … A full pass finds no example with y⟨w,x⟩ ≤ 0 (smallest y⟨w,x⟩ = 1.25). Converged after 12 updates: w = (3, 3.5), b = -6.

Simplified: 2-D toy data (at most 12 points on a half-unit grid) and a deterministic 'first mistake in list order' rule; the textbook allows any example with y⟨w,x⟩ ≤ 0. The update cap stands in for 'run forever'.

Educational simulation

Loading the simulation…