b2KIT

Perceptron Learning Visualizer

Train a single perceptron on 2D data. Watch the decision boundary move as weights update with each training sample.

Tested tool guide Tested browser tools Checked August 16, 2026

What Perceptron Learning Visualizer does, with a checked example

This tool trains a single-layer perceptron against 2D points you place and label by class. Each point is fed through a step activation one at a time; when the perceptron misclassifies it, the tool nudges the weight vector and bias in the direction that would have fixed that one point, then redraws the decision boundary immediately. People are usually surprised that convergence is not guaranteed: if the two classes can't be separated by a straight line, the boundary keeps sliding and never settles - that's expected behavior, not a bug in the tool.

Worked example

A concrete input and expected output from the current implementation.

Input

Two labeled points: (1, 1) -> +1 and (-1, -1) -> -1. Start weights w1=0, w2=0, bias=0, learning rate=1, step activation returns +1 when w1*x1 + w2*x2 + b >= 0, else -1.

Expected output

After (1,1): output is +1 (sum = 0, meets >=0), matches target, no update. After (-1,-1): output is still +1 (sum = 0) but target is -1, so weights update to w1=2, w2=2, bias=-2.

The rule is w += lr*(target-output)*x and b += lr*(target-output). On the second point, target-output = -1-1 = -2, so adding -2*(-1,-1) = (2,2) to the weights and -2 to the bias is exactly what pulls the boundary toward classifying that point correctly.

How the result is produced

1

Per-sample weight update

After you label each point, the tool computes w1*x1 + w2*x2 + b, applies a step activation to get +1 or -1, and compares it to the point's true label. On a misclassification it applies the perceptron rule w = w + lr*(target-output)*x and b = b + lr*(target-output) using the learning rate you set, then advances to the next point in sequence.

2

Boundary redraw

The current weight vector [w1, w2] and bias b define the line w1*x + w2*y + b = 0 on the plotted plane. After every update the tool recomputes this line and redraws it, so the boundary visibly rotates and slides sample by sample instead of jumping straight to whatever line it eventually converges on.

Good uses

  • checking whether a small hand-placed dataset is linearly separable by watching whether the boundary stops moving
  • walking through the perceptron learning rule step by step for a class or self-study session
  • seeing how learning rate or the order points are presented changes the path the boundary takes

Limits and checks

  • If the two classes overlap or aren't linearly separable, the boundary never stabilizes - the visualizer cycles indefinitely rather than telling you the dataset is inseparable.
  • Because updates happen one point at a time, the order points are added or replayed changes the path taken and can change which valid separating line is ultimately reached.
  • A single perceptron only produces a straight-line boundary; it cannot represent curved or disjoint regions (e.g. XOR-style layouts) no matter how long training runs.

Common questions

Why does the boundary keep swinging back and forth instead of settling?

That happens when your labeled points are not linearly separable - no straight line correctly splits both classes, so every pass leaves at least one misclassified point and triggers another update. This is expected: the perceptron convergence guarantee only holds for linearly separable data, so persistent movement is itself informative.

Will a different learning rate produce a different final boundary?

Yes, potentially. On separable data the perceptron is only guaranteed to reach some line that separates the classes, not a unique one - a different learning rate changes the update step size and path, which can land on a different (still correct) boundary and change how many points it takes to get there.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools