Classification · Part 3
From a hand-set threshold for AND to a learned separator. XOR shows the limit of a single straight boundary.
6 · ClassificationHow can we classify by location?
In Part 2, we used nearby examples to classify a new point. Now we’ll focus on the geometry of the decision. What separates the parts of the plot that get different labels?
A separator, also called a discriminant, is a decision rule that divides the input space into regions. A new point gets the label of the region it lands in. With C classes, there are C prediction regions, one for each label. For two classes, a straight line can serve as the boundary if the classes lie on opposite sides.
Can one line separate the two classes in a plot of switch settings? We’ll start with logical AND, set a rule by hand, then see how a perceptron can learn one from examples. Later, we’ll try the same idea on XOR to see where a single straight boundary falls short.
- 6.1 · McCulloch & Pitts Neuron
- 6.2 · Perceptron
- 6.2.1 · Learning rate
- 6.2.2 · What’s next
6.1 · McCulloch & Pitts NeuronThe AND problem starts with four switch settings
Each switch is off (0) or on (1). Our task is to predict the output of logical AND, which is 1 only when both switches are on.
In the plot, the first switch gives the horizontal coordinate, the second gives the vertical coordinate, and the output gives the class. Try drawing a line that leaves the three class-0 points on one side and the class-1 point on the other.
Each row is one test. The observation index i tells you which test to read. The feature index j tells you which switch to read in that test. In test 3, the second switch is off, so x32 = 0.
| Test i | First switch j = 1 | Second switch j = 2 | Class Y |
|---|---|---|---|
| 1 | 0 | 0 | 0 |
| 2 | 0 | 1 | 0 |
| 3 | 1 | 0 | 0 |
| 4 | 1 | 1 | 1 |

Static preview. Open handout.html to use the interactive example.
6.1 · McCulloch & Pitts NeuronHow can a threshold neuron model AND?
For each switch setting xᵢ, the neuron adds the two inputs. The sum counts how many switches are on. The neuron predicts 1 when the score reaches the threshold b, and 0 otherwise. To model AND, only the setting (1, 1) should reach b.
The McCulloch & Pitts neuron is a simplified model of a firing neuron. In the plot, (1, 0) and (0, 1) each give a score of 1, and (1, 1) gives a score of 2. The designer sets b by hand. The indicator returns 1 when its condition holds, including equality at b. On the next slide we plug the switch settings into both formulas and compare two thresholds.
Open the corresponding slide ↗6.1 · McCulloch & Pitts NeuronWork out the neuron’s output for two thresholds
Each row i is one switch setting. Here m = 2. Add the two inputs to get g(xᵢ), subtract b, then use the indicator 𝟙. It gives 1 for zero or positive results and 0 otherwise.
| Row i | First input xi1 | Second input xi2 | Sum g(xᵢ) | Threshold b = 2 | Threshold b = 2.5 | ||
|---|---|---|---|---|---|---|---|
| g(xᵢ) − b | Output ŷᵢ | g(xᵢ) − b | Output ŷᵢ | ||||
| 1 | 0 | 0 | 0 + 0 = 0 | 0 − 2 = −2 | 𝟙(−2 ≥ 0) = 0 | 0 − 2.5 = −2.5 | 𝟙(−2.5 ≥ 0) = 0 |
| 2 | 0 | 1 | 0 + 1 = 1 | 1 − 2 = −1 | 𝟙(−1 ≥ 0) = 0 | 1 − 2.5 = −1.5 | 𝟙(−1.5 ≥ 0) = 0 |
| 3 | 1 | 0 | 1 + 0 = 1 | 1 − 2 = −1 | 𝟙(−1 ≥ 0) = 0 | 1 − 2.5 = −1.5 | 𝟙(−1.5 ≥ 0) = 0 |
| 4 | 1 | 1 | 1 + 1 = 2 | 2 − 2 = 0 | 𝟙(0 ≥ 0) = 1 | 2 − 2.5 = −0.5 | 𝟙(−0.5 ≥ 0) = 0 |
With b = 2.5, even (1, 1) falls below the threshold. Every row predicts 0.
Use the same four observations for each threshold. In row 4, x₄₁ = 1 and x₄₂ = 1, so g(x₄) = 2. At b = 2, g(x₄) − b = 0, and the indicator 𝟙(0 ≥ 0) returns 1. At b = 2.5, the same sum gives −0.5, and 𝟙(−0.5 ≥ 0) returns 0. Checking whether g(xᵢ) − b is at least zero is equivalent to checking whether g(xᵢ) is at least b. The next slide finds every b that gives the AND outputs.
Open the corresponding slide ↗6.1 · McCulloch & Pitts NeuronWhich thresholds reproduce AND?
| X₁ | X₂ | X₁ + X₂ | Y |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 2 | 1 |
Keep class 0 below the threshold
The largest class-0 sum is 1. A threshold of 1 would also fire for a single active input.
Let class 1 reach the threshold
The only class-1 row has sum 2. A threshold of 2 still fires at equality.
Combine the two bounds
This interval contains every threshold that classifies all four AND inputs correctly.
Class 0 requires its sum to be strictly below b because the neuron fires at equality. The three class-0 rows therefore give 0 < b, 1 < b and 1 < b. Class 1 requires 2 ≥ b. Combining them gives 1 < b ≤ 2. For example, b = 1.9 satisfies both bounds.
Open the corresponding slide ↗6.1 · McCulloch & Pitts NeuronHow does moving the boundary change AND?
Start at b = 1.9 and find the only input on the class-1 side. Then try b = 1 and b = 2. Which points land on the line, and what does the neuron predict for them?
At b = 1.9, the line x₁ + x₂ = 1.9 separates (1, 1) from the other three inputs. At b = 1, both single-switch inputs lie on the line and predict 1, so the rule acts like OR. At b = 2, (1, 1) lies on the line and still predicts 1. We choose b by hand in this neuron. Select OR to compare the required thresholds.

Static preview. Open handout.html to use the interactive example.
6.2 · PerceptronThe machine that learned to read letters

In 1958, Frank Rosenblatt asked how memory changes what we recognize.
“In what form is information stored, or remembered?”
The Mark I saw a letter through 400 light sensors. Its adjustable weights were physical components turned by little motors.
A trainer corrected the machine when it guessed wrong. We’ll do the same with the weights of a separator.
Rosenblatt’s 1958 paper, p. 386 · Hardware details, fig. 4.8
The Navy’s photo caption reported perfect recognition in the typeface used for training and 85% after letters in another typeface were added. That is an early example of a generalization question. If the shape of the letters changes, will the same learned weights still work?
6.2 · PerceptronThe four AND inputs become four clouds
Inspect how the input coordinates vary. The upper-right cloud still has class 1.
The 360 observations vary around the four ideal corners. The target remains class 1 for the upper-right cloud. This motivates learning a weighted separator from examples.
Static preview. Open handout.html to use the interactive example.
6.2 · PerceptronThe perceptron learns a weighted threshold rule
To separate the noisy classes, the perceptron uses a weighted McCulloch & Pitts neuron (MPN). It learns the weights w = (w₀, …, wₘ) from labeled examples, so some inputs can have more influence than others.
Why are the forms equal? The sum starting at j = 0 includes the term w₀xᵢ₀. Since xᵢ₀ = 1 for every observation, that term is just w₀. The second form writes it outside the sum.
Setting every feature weight to 1 and w₀ = −b gives the original MPN rule with threshold b.
A perceptron is a threshold neuron with learnable weights and bias. A positive weight raises the score as its feature increases, and a negative weight lowers it. In two dimensions the score-zero line separates the predicted classes. Learning the weights lets the model change the line’s direction, and the bias shifts its position. Writing the constant input xᵢ₀ = 1 lets us use the same update rule for the bias and the other weights.
Open the corresponding slide ↗6.2 · PerceptronHow does a perceptron learn its weights?
Predict
A score of 0 predicts class 1.
Compare
Adjust the weights
Try turning each switch on or off. Each combination starts with zero weights and shows one training example. The initial score of 0 predicts class 1. The AND label is 1 only when both switches are on. For the starting input (1, 0), the AND label is 0. With the update rule on the next slide, this mistake decreases the bias and the first weight by one each. The second weight stays zero. The score for (1, 0) becomes −2, and the same input now predicts class 0. Training then uses the updated weights for the next example. A correct prediction leaves them unchanged.
Open the corresponding slide ↗6.2 · PerceptronUse the prediction error to update the weights
The update is inspired by Hebbian learning, a principle that links connection strength to neuron activity. The perceptron uses the known label to decide how to correct its prediction.
| Observed label | Predicted label | Change to each weight |
|---|---|---|
| 0 | 0 | Keep the weights |
| 1 | 1 | Keep the weights |
| 1 | 0 | Add each input component |
| 0 | 1 | Subtract each input component |
For each observation, compute the prediction with the current weights, then use that prediction error to update each weight. The same rule applies to the bias because xᵢ₀ = 1. The index t counts the observations processed during training.
Open the corresponding slide ↗6.2 · PerceptronWhen has the perceptron finished learning?
Apply the update rule to each observation in turn. After one pass through the training set, start another pass with the latest weights.
When convergence is guaranteed
If the training classes are linearly separable, the perceptron finds a separator after finitely many updates. With two features, a straight line can separate the classes.
How to tell it has converged
Check for one complete pass with no mistakes. Every weight stays the same throughout that pass, so the same rule correctly classifies every training example.
Here convergence means that a full pass makes no updates. A single correct prediction also leaves the weights unchanged for that step. To check convergence, continue through every observation. The finite-update guarantee applies to the standard perceptron on a finite, linearly separable training set. The lab caps the number of passes so that runs on XOR can end.
Try the training example on the slides ↗6.2 · PerceptronWhy does the correction move the score?
Compare the weighted score for the same example before and after one update. Zero or more predicts class 1. A negative score predicts class 0.
Correct prediction
The predicted class matches the observed class, so yᵢ − ŷᵢ = 0. The update adds 0 to every weight, leaving the score for this example unchanged.
Missed a class 1
The true class is 1 and the prediction is 0. Put the error 1 − 0 into the update rule for one weight.
In the right sum, the xᵢⱼ inside the parentheses comes from this weight update. The xᵢⱼ outside is the input we multiply by to score the same example again.
Expand the product
In the right-hand sum, multiply the outside xᵢⱼ by both terms in parentheses. The old weight gives wⱼ⁽ᵗ⁾xᵢⱼ. The added input gives xᵢⱼ × xᵢⱼ = xᵢⱼ².
Separate the sums
Collect the old weighted inputs into the first sum. That is the old score. The second sum adds the squared inputs. This increases the score because xᵢ₀ = 1 contributes 1². The prediction becomes 1 when the new score reaches zero or above.
Predicted 1 by mistake
Now the true class is 0 and the prediction is 1, so the error is −1. Each new weight is the old weight minus its input. The same multiplication gives old score minus the sum of squared inputs. A negative new score predicts class 0.
Read steps 2–4 as three lines of the same calculation for a missed class 1. Step 5 switches to the opposite mistake. Each correction moves the score of that example toward the right class. For example, if a missed class 1 starts at −3 and the sum of squared inputs is 2, the score rises to −1 and still predicts 0.
Open the corresponding slide ↗Which formulas do we use for one update?
Use the old score and the change in each weight to rescore the same example.
- Find each weight change. Multiply the learning rate by the prediction error and by the input for that weight.
- Compute the new score. Multiply each weight change by its input again. Add these contributions to the old score.
- Predict the class. Check the new score against zero.
6.2 · PerceptronStep through perceptron learning
Choose Next example to follow the circled point. Compare its prediction before the update with its score afterward.
Try AND with the default order and learning rate η = 1. The weights are listed in order (w₀, w₁, w₂). Compute the old score as w₀ + w₁x₁ + w₂x₂, and predict 1 if the score is zero or higher. The first point (0, 0) has target 0 but starts with score 0, so its prediction is 1. Its error is −1. The correction is (−1, 0, 0) because both features are zero and the bias uses a constant input of 1. The new score is −1, so the same point now predicts 0. A line appears once a feature weight changes and the boundary enters the plot. Use Back to revisit an example. Finish pass processes the rest of the current pass and displays its final example. Training stops after a complete pass with no mistakes or after 25 passes.

Static preview. Open handout.html to use the interactive example.
6.2 · PerceptronInspect a trained perceptron on noisy AND
This trained perceptron separates all 360 noisy training points. Select a point to see which side of the learned line it falls on.
A line can separate these training classes, so the convergence guarantee applies. The step-through lab may reach a different valid line because the training order and starting weights affect the updates.
Static preview. Open handout.html to use the interactive example.
6.2.1 · Learning rateThe learning rate controls the size of a correction
One mistake
Doubling η doubles the size of that weight correction.
A complete run
With zero initial weights, fixed order and constant positive η, the weights scale with η and the mistake sequence stays the same in exact arithmetic.
A learning rate sets the update scale. Try 0.25, 1 and 4 in the training lab. In this classic zero-initialized setup, the sign of each score is unchanged by positive rescaling, so the number of mistakes is unchanged. Effects on speed and numerical stability depend on the setup. The basic rule uses η = 1.
Open the corresponding slide ↗6.2.2 · What’s nextTry to separate the four XOR points
Change AND to “exactly one switch is on.” Can you draw a single line that separates the two labels?
XOR outputs 1 when exactly one input equals 1. The class-0 points are (0,0) and (1,1), and the class-1 points are (1,0) and (0,1). Both classes have the same midpoint (½,½). A single straight separator cannot put their line segments on opposite sides. Try XOR in the perceptron lab to see the updates continue.
Static preview. Open handout.html to use the interactive example.
6.2.2 · What’s nextWhy one line cannot separate XOR
Class 0 at (0,0) and (1,1)
Class 1 at (1,0) and (0,1)
Adding the two class-1 inequalities gives w₁ + w₂ + 2w₀ ≥ 0. Since the score at (0,0) requires w₀ < 0, this implies a positive score at (1,1), contradicting its class-0 label. The two classes occupy opposite corners. A multilayer perceptron can solve XOR, as can a suitable nonlinear representation.
Open the corresponding slide ↗6.2.2 · What’s nextFour points, one line, and a famous book
Marvin Minsky and Seymour Papert’s 1969 book Perceptrons studied the limits of this kind of classifier. XOR is the smallest parity example. It asks whether the number of active inputs is odd.
What made it worth studying
“worthy of study despite (and even because of!) its severe limitations”
We just saw one such limit. A straight line through the two original features cannot separate XOR.
What they left open
“elucidate (or reject) our intuitive judgment that the extension is sterile”
They were skeptical that adding layers would yield a useful learning rule. Their wording invites a test of that conjecture.
Minsky & Papert, Perceptrons (1969) · §13.2, pp. 231–232
The book’s analysis covered more than XOR, including parity and connectedness under restrictions on the units. The two-input example gives us a concrete way to see why the choice of features matters. A new intermediate feature can change which labels a straight line can separate.
6.2.2 · What’s nextWhat cooled during the first AI winter?
The first AI winter was a period of reduced interest and funding for parts of AI research. The perceptron debate was one part of a broader slowdown.
1960s · Funding was already tightening
Rosenblatt struggled to secure funding for larger projects before the 1969 book appeared.
1973 · The UK scrutinized AI
James Lighthill’s review asked why methods that worked on small examples struggled as the number of possibilities exploded.
1986 · XOR returned as a test case
Rumelhart, Hinton and Williams showed how backpropagation could train hidden units that let a network solve XOR.
Funding history · Lighthill’s report · The 1986 XOR experiments
Lighthill’s report discussed a broader concern familiar from the search lectures. Adding more possibilities can make a small working demonstration very expensive at a realistic scale. Meanwhile, researchers kept working on neural networks. To see what a hidden unit changes, give the XOR classifier one extra feature that turns on when both inputs are 1. Add the two input values and subtract twice that feature. The result is 1 for the two cases with exactly one active input and 0 for the other two. This is a concrete feature the output can use to separate the classes.
Lecture recapWhat to take away
- Use an input sum and a threshold to reproduce AND.
- Explain how a perceptron learns by correcting mistakes.
- Use XOR to explain the limits of a single linear separator.
Further readingBishop on classification
Read chapters 4 and 7 for linear discriminants, perceptron learning, and support vector machines.
Open the corresponding slide ↗