Week 01 lab · 2D classification
Interactive perceptron
Give the model examples from two groups. Pick a class, then click the graph or enter coordinates. The model retrains after every new point.
Click anywhere inside the graph to add the selected class.
Pseudocode
How it learns.
weights ← [0, 0]
bias ← 0
repeat up to 100 times:
mistakes ← 0
for each point:
score ← w₁x + w₂y + bias
guess ← +1 if score ≥ 0, otherwise −1
if the guess is wrong:
weights ← weights + label × [x, y]
bias ← bias + label
mistakes ← mistakes + 1
stop when mistakes = 0