One hyperplane, four points, four signed distances
numeric▲△△All values rounded to 4 d.p.
STATEMENT
A perceptron’s parameters are given. Write the equation of its decision boundary, classify four points, and compute each point’s signed distance from the boundary.
GIVEN
and the four points
FIND
The boundary as an equation in ; the predicted label of each point; and each signed distance, a scalar in the same units as the coordinates.
STRATEGY
Compute the raw score once per point. The sign of gives the class and gives the distance, so one quantity answers both questions.
SOLUTION
Step 1 — the boundary. By Definition 2 the boundary is the set where the score is zero:
A line of slope through . Note that is perpendicular to it: the direction along the line is , and . The weight vector is always the normal to the boundary. That single fact makes every later step geometric rather than algebraic.
Step 2 — the norm. Needed once, for all four points:
Step 3 — the scores.
Step 4 — labels and distances. Divide each score by (Projections and orthogonality 0.LA.05):
| Point | Score | Distance | Class |
|---|---|---|---|
Answer
Boundary: .
Classes: and . Distances are scalars in the units of the coordinate axes; the scores are not, which is why the division by is not optional.
Check — numeric · i-2-b01-decision-boundary.py
norm = sqrt(w[0] ** 2 + w[1] ** 2)
score = w[0] * x[0] + w[1] * x[1] + b
dist = score / normPrints ||w|| = 2.2361 and the four distances above.
Executed in CI. The digits above are the digits it printed.
Check — sanity
A point on the boundary has distance zero. Take , which satisfies . Its score is , so its distance is . The formula agrees with the definition it came from.
Rescaling the parameters changes nothing geometric. Double both: , . Then and , so the distance is — unchanged. The scores doubled and the distances did not, which is exactly the difference between the functional margin (Definition 4) and the geometric one (Definition 5).
Moving a point along the boundary direction changes nothing. Shift by , the direction along the line, to get : its score is , identical. Moving perpendicular to cannot change the score, because is what the score measures against.
Where this breaks
The distance formula requires . At the score is the constant for every input, the “boundary” is empty or all of , and the division is undefined. That is not a pathological corner: it is the state a perceptron is initialised in, which is why the first update of I.2.B02 has margin exactly zero and the rule must treat rather than as a mistake.
Variation
Keep and change from to . Predict, before computing, which points change class — then verify, and state in one sentence what the bias does geometrically.