Rosenblatt, F. (1958). "The perceptron: A probabilistic model for information storage and organisation in the brain". Psychological Review. 65 (6): 386–408.
https://doi.org/10.1037%2Fh0042519
Perceptron
We'll start our journey in 1958 with the following equation:
where is the activation function, is the weight vector, is the input vector, and is the bias. We can also absorb into the weight vector by adding an extra 1 to .
In 1958, the activation function was the Heaviside step function:
Let there be DATA
We organise data into a matrix and a vector
For example, consider logical AND:
then a single data point is and . Usually, capital bold is matrix, lower case bold is vector and lower case is scalar.
It is difficult to find a single convention to write these equations and they vary between textbooks. My advice just go with it.
Let there be learning
where is the learning rate, is the true label, and is the predicted label.
Error
Prediction State
Weight Update Action
False Negative ()
(pulls towards )
False Positive ()
(pushes away from )
Correct classification
No change to
Very underwhelming to say machine learning is just an equation we update. If this upsets you, be prepared for disappointment.
Learning in action
What about XOR?
Minsky & Papert, 1969
What could they have possibly done to start the AI winter?
Perceptrons: An Introduction to Computational Geometry
By: Marvin Minsky, Seymour A. Papert
XOR Contradiction: 1. Setup
0
0
0
0
1
1
1
0
1
1
1
0
Perceptron Classifier
A single-layer perceptron classifies via an affine hyperplane threshold:
XOR Contradiction: 2. Four Inequalities
Assume there exist real parameters such that the perceptron correctly classifies all 4 XOR inputs:
Input
Target
Condition
Inequality Label
0
1
1
0
3. Deriving the Contradiction
Summing Class 1 ()
Add inequalities (2) and (3):
Summing Class 0 ()
Add inequalities (4) and (1):
Hint: Notice that the left-hand sides of (A) and (B) are identical!
4. Contradiction
Comparing (A) and (B)
Define . The simultaneous system requires:
Conclusion
A real scalar cannot be strictly positive and non-positive simultaneously:
A single-layer perceptron cannot compute the XOR function!
Show me the code: Perceptron
sklearn is a popular library for machine learning in Python. All the classic non-deep learning algorithms you might ever use or don't use are in there.
from sklearn.linear_model import Perceptron
# Logical AND truth table
X = [[0, 0], [0, 1], [1, 0], [1, 1]]
y = [0, 0, 0, 1]
clf = Perceptron()
clf.fit(X, y)
print("Predictions:", clf.predict(X)) # [0, 0, 0, 1]print("Accuracy: ", clf.score(X, y)) # 1.0
k-Nearest Neighbours
Would you believe that the simplest non-trivial algorithm can solve XOR? Easy.
1. Neighbourhood Identification
Given training set and query point , find the closest instances :
For (closest example):
2. Decision Rule
Majority Voting (Classification):
Class Probability Estimate:
Mean Value (Regression):
k-Nearest Neighbours: Geometric Intuition
1-NN Voronoi Tessellation: Partitions the space into convex polyhedra. Each cell shares the label of its generating point.
Solves XOR naturally: Non-linear decision boundaries emerge from local piecewise linear facets!
What does "near" mean?
The notion of similarity or distance is key to many machine learning algorithms.
Let me repeat that: It is very very important to be able to measure similarity of things.
You have probably seen different distance metrics before:
Manhattan distance:
Euclidean distance:
Chebyshev distance:
It is very very important to be able to measure similarity of things.
Minkowski Distance: -norms
Minkowski Distance ( norm): General family parameterised by :
Show me the code: -Nearest Neighbours
Unlike the Perceptron, 1-NN solves non-linearly separable XOR easy peasy: