This week at a glance
- By the end you can
- explain why "intelligence" is hard to define, using real examples;
- tell the difference between a system that follows a fixed rule and one that learns;
- ask four kinds of question about any intelligent system: mechanism, theory, generalisation and measurement;
- turn a vague claim into a prediction that could turn out wrong, and test it with a short program;
- label a claim by how strong the evidence for it is.
- You need
- Basic Python: variables,
if, loops, functions and dictionaries. No maths beyond fractions. - Files
week01_umbrella.py, the experiment in Section 5. Standard library only.
1Why ask the question at all?
Computers can now translate languages, recognise faces, write working code and beat world champions at Go. A reasonable reaction is: if we can build these things, surely we already understand intelligence?
Not quite. Being able to build something and being able to explain it are different achievements. People made bread for thousands of years before anyone knew that yeast is a living organism that produces gas. The bread was real. The understanding came later, and when it came it let bakers predict and fix things they could not before: why dough fails to rise in the cold, why too much salt slows it down.
Flight is an even better example for this course. Birds fly, and so do aeroplanes. They are built from completely different materials and work in visibly different ways: birds flap, planes do not. Yet the same principles of aerodynamics explain both. Air moving over a wing produces lift whether the wing is made of feathers or aluminium. That is what a good theory gives you: an explanation that holds across very different systems, and that predicts what will happen to a design nobody has built yet.
This course asks whether intelligence has principles like that. Is there something that explains why a child, a crow and a computer program can all learn from experience, the way aerodynamics explains both birds and planes? Or is intelligence a collection of separate tricks with nothing deep in common? Nobody knows yet. That is the honest starting point, and it is why the course is about doing science, not just learning facts.
Building something that works is engineering. Explaining why it works, well enough to predict new cases, is theory. This course is mainly about the second.
2Trying to define intelligence
Let us start with an exercise. Below are seven systems. For each one, decide whether you would call it intelligent before reading on.
- A fan that switches on when the room is above 28 °C.
- A calculator.
- An email spam filter that improves as you mark messages as spam.
- A chess program that beats every human alive.
- A crow that bends a piece of wire into a hook to pull food out of a tube.
- A two-year-old learning new words.
- A chatbot that answers questions in fluent English.
Most people find they disagree with each other, and often with themselves. The calculator is far better at arithmetic than you are, but it feels wrong to call it intelligent. The chess program is superhuman at chess and useless at everything else. The crow cannot do arithmetic at all, yet solving a new problem with a tool it made itself feels like a clear case of intelligence.
Your disagreements are useful. They show that we use the word for several different properties at once. Pulling them apart is the first step.
| System | Pursues a goal? | Learns from experience? | Copes with new situations? | Works across many tasks? |
|---|---|---|---|---|
| Fan controller | Yes, simply | No | No | No |
| Calculator | No | No | No | No |
| Spam filter | Yes | Yes | Partly | No |
| Chess program | Yes | Depends how built | Within chess | No |
| Crow with wire | Yes | Yes | Yes | Partly |
| Two-year-old | Yes | Yes | Yes | Yes |
| Chatbot | Debated | During training | Partly | Partly |
Three serious attempts at a definition
Researchers have proposed many definitions. Here are three you will meet again. Each captures something real, and each has a weakness.
- Turing, 1950
- Alan Turing suggested replacing "Can machines think?" with a test: if a judge chatting by text cannot reliably tell a machine from a person, we should take the machine seriously. Strength: it uses behaviour we can observe instead of arguing about inner experience. Weakness: it rewards seeming human, and only in conversation. A system could fail it and still be very capable, or pass it with clever tricks.
- Legg and Hutter, 2007
- Their informal version: intelligence "measures an agent's ability to achieve goals in a wide range of environments." Strength: it is general, and they turned it into a precise mathematical formula. Weakness: the formula cannot actually be computed, and it depends on how you choose and weight "environments".
- Chollet, 2019
- François Chollet argues that intelligence is how efficiently a system turns its prior knowledge and experience into new skills. A system that needs millions of examples to learn what a child learns from three is less intelligent at that task, even if it ends up equally skilled. Strength: it separates skill from the ability to acquire skill. Weakness: measuring "prior knowledge" fairly across humans and machines is very hard.
"Good at a task" and "intelligent" are not the same thing. The chess program shows that superhuman skill on one task tells you little about general ability. Throughout this course, a high score on one test is evidence about that test, not proof of a general property.
This course does not pick one winning definition on day one. Instead it does what scientists do with any slippery concept: it breaks the big word into smaller properties that can be measured, such as learning, memory, prediction and adaptation, and studies each one carefully. Whether those pieces add up to one thing called "intelligence" is itself one of the open questions.
3Fixed rules and learning
One distinction does a lot of work, so let us make it concrete with code. Here is the fan controller from the list above.
def fan_controller(temperature):
# A fixed rule: the same input always gives the same output, forever.
if temperature > 28:
return "fan on"
return "fan off"
This system has a goal of sorts (keep the room comfortable), but nothing that happens to it ever changes its behaviour. If you always find 26 °C too warm, it will never notice.
Now a version that learns from feedback:
class LearningFan:
def __init__(self):
self.threshold = 28.0 # starting guess
def decide(self, temperature):
return "fan on" if temperature > self.threshold else "fan off"
def feedback(self, complaint):
# Experience changes the rule itself.
if complaint == "too hot":
self.threshold -= 0.5
elif complaint == "too cold":
self.threshold += 0.5
fan = LearningFan()
for complaint in ["too hot", "too hot", "too hot", "too hot"]:
fan.feedback(complaint)
print(fan.threshold) # 26.0: it now switches on two degrees earlier
The difference is small in code and large in meaning. In the first program, the programmer decided the behaviour. In the second, the programmer decided how behaviour changes, and the person's complaints decided the rest. The second system adapts to a situation its programmer never saw.
Notice what the learning fan still cannot do. It only adjusts one number, in steps of 0.5, in one direction at a time. If the real problem is humidity, not temperature, no amount of complaining will help, because humidity is not something it can represent. What a system can represent limits what it can learn. That idea returns in almost every week of this course.
A fixed rule maps situations to actions once and for all. A learner has a rule for changing its rule. A learner can only learn about things it has some way of representing.
4Four levels, one example
The course asks four kinds of question about any intelligent system. We will use one running example to see them side by side.
The umbrella problem. Every morning you decide whether to carry an umbrella. Carry it and it does not rain, and you have lugged it around for nothing. Leave it and it rains, and you get soaked. You can look at the sky, and you can remember the last few days. Somewhere in the background there is a season: in the rainy season it rains often, in the dry season rarely. You never see the season directly. You only see its effects.
- Mechanism
- How does the system decide? For example: "Count how many of the last three days were rainy. If the sky is cloudy and at least two were rainy, take the umbrella."
- Theory
- Why does that mechanism work, and when would it fail? Perhaps: "Remembering past days helps because the season lasts a long time, and recent rain tells you which season you are in. If seasons changed every day, memory would not help."
- Generalisation
- Does the same principle hold elsewhere? A doctor using a patient's history, a trader watching a market and a farmer deciding when to plant also face hidden conditions that last. Does the same explanation work for them?
- Measurement
- How do we score it fairly? The fraction of correct umbrella decisions, perhaps. But is a soaking worse than carrying it for nothing? And should we count how much memory the system uses?
These levels are connected. The theory explains the mechanism; generalisation tests whether the theory is about umbrellas or about something deeper; measurement is how we check any of it. A complete answer to "how does this system work?" usually needs all four.
Hidden things that last
The umbrella problem has a feature worth naming now, because it will matter all term. The thing that really determines tomorrow's weather, the season, is hidden. Today's sky is only a noisy clue to it. But the past carries extra clues, because the season does not change overnight. Memory is useful exactly because it lets you piece together something about the hidden state that the present moment alone does not show.
That gives us a theory with teeth: memory should help when a hidden condition lasts long enough for the past to tell you about the present, and should not help when it does not. Notice that this claim could be wrong. That is what makes it worth testing.
5Your first experiment
We will test the theory with a short program, week01_umbrella.py. It has four parts.
- A simulated world. Each day the hidden season might switch. In the rainy season it rains 70% of the time; in the dry season, 15%. The morning sky is cloudy 60% of the time on days it will rain, and 30% on days it will not, so the sky is a useful but imperfect clue.
- What the agent sees. Today's sky, plus how many of the last k days were rainy. With k = 0 it has no memory at all.
- Learning by counting. For 20,000 training days, the agent records each situation it saw and whether it rained. Its rule is then simple: in a given situation, take the umbrella if it rained more than half the time.
- Testing on new days. The rule is scored on 20,000 days it has never seen.
Here is the heart of it: the learner and the scorer.
def train(days, k):
counts = defaultdict(lambda: [0, 0]) # situation -> [rainy days, total days]
for t in range(k, len(days)):
seen = what_agent_sees(days, t, k)
counts[seen][0] += days[t][1] # add 1 if it rained
counts[seen][1] += 1
# Take the umbrella where it rained more than half the time.
return {seen: rain / total > 0.5 for seen, (rain, total) in counts.items()}
def score(rule, days, k):
right = 0
for t in range(k, len(days)):
take = rule.get(what_agent_sees(days, t, k), False)
right += take == days[t][1]
return right / (len(days) - k)
"It rained on 62 out of 100 cloudy mornings after two rainy days" is an estimate of a conditional probability: the chance of rain given what you saw. Counting is the simplest way to estimate one. Week 2 makes this idea precise.
Predict before you run
A scientific habit starts here. Before running anything, write down what you expect. Our theory says:
- In a world where seasons last a long time, more memory should improve accuracy.
- In a world where the season flips at random every day, memory should not help at all.
If the second world showed a big benefit from memory, the theory would be in trouble.
What happened
| Memory k (days) | Seasons last ~50 days | Season flips at random daily |
|---|---|---|
| 0 (sky only) | 0.656 | 0.658 |
| 1 | 0.672 | 0.658 |
| 3 | 0.711 | 0.658 |
| 7 | 0.729 | 0.657 |
| 14 | 0.717 | 0.658 |
Both predictions held. With long seasons, a week of memory lifts accuracy from about 66% to about 73%. With random daily seasons, memory is useless: every column is the same to two decimal places. The same learning method, with the same memory, helps in one world and does nothing in the other. What made the difference was a property of the world: how long the hidden condition lasts.
The surprise
Look again at the long-season column. Accuracy rises up to 7 days and then falls at 14. More memory made things worse. Our theory did not predict this.
One possible explanation: when the season switches, a 14-day memory is still full of days from the old season, so the agent is slow to notice the change. A 7-day memory "forgets" the old season sooner. That is a reasonable idea, but we have not tested it. So we label it honestly:
Exploratory observation In this simulation, 14 days of memory did slightly worse than 7. The "slow to notice a switch" explanation is untested.
You will test it in seminar exercise 2. This is exactly how research is supposed to go: a prediction, a result, a surprise, and a new, sharper question.
This is one small simulated world with numbers we chose. It shows that the theory can work; it does not show that memory works this way in brains, markets or large AI systems. Claiming more than the evidence supports is one of the most common mistakes in the field.
6Labelling what we know
The course labels every research claim by how strong its evidence is. You have just used one label. Here are all five, with everyday examples.
- Established result
- Supported by a large body of evidence, within a clearly stated scope. Example: people remember material better when their study is spread over several sessions than when it is crammed into one. This "spacing effect" has been found in hundreds of studies over more than a century. Our umbrella result is not established: it comes from one program, one set of numbers and one random seed.
- Replicated finding
- Seen again by someone else, independently, under similar conditions. Example: a classmate writes their own simulation from scratch and also finds memory helps when seasons last.
- Working hypothesis
- A proposed explanation not yet properly tested. Example: "memory helps whenever a hidden condition outlasts the memory window", stated as a general rule.
- Exploratory observation
- A pattern noticed, worth investigating. Example: the dip at 14 days.
- Open question
- The evidence does not yet support an answer. Example: do children and animals use memory according to the same principle?
The labels are not permanent. An exploratory observation can become a working hypothesis once someone proposes a testable explanation, and a working hypothesis can be overturned. Keeping track of which is which protects you from fooling yourself.
7Summary
- Building intelligent systems and explaining intelligence are different achievements. This course focuses on explanation.
- "Intelligence" bundles several properties: pursuing goals, learning, coping with novelty, breadth. Skill at one task is not the same as general ability.
- A fixed rule never changes; a learner has a rule for changing its rule. What a system can represent limits what it can learn.
- We study systems at four levels: mechanism, theory, generalisation and measurement.
- A useful theory makes predictions that could fail. Our umbrella theory predicted when memory helps, and passed its first test.
- Unexpected results, like the dip at 14 days, are labelled honestly and turned into new questions.
·Key terms
- Agent
- Anything that observes its situation and chooses actions: a program, a robot, an animal, a person.
- Environment
- Everything outside the agent that responds to its actions and produces what it observes.
- Fixed rule
- A mapping from situations to actions that never changes with experience.
- Learning
- A change in behaviour caused by experience, usually through a rule for updating the agent's own rule.
- Hidden state
- Something that affects what happens but cannot be observed directly, such as the season in the umbrella problem.
- Memory
- Information an agent keeps from the past and uses now.
- Generalisation
- Performing well on situations not seen during learning. Also: a principle holding beyond the system where it was found.
- Prediction
- A statement, made in advance, of what an experiment will show, specific enough that it could be wrong.
- Conditional probability
- The chance of something given that you know something else; for example, the chance of rain given a cloudy morning.
·Check your understanding
Try each question before opening the answer.
- A calculator is far better at arithmetic than any human. Using Table 1, explain in two sentences why most people still would not call it intelligent.
Show answer
It is excellent at one fixed task, but it does not learn from experience, cannot cope with new kinds of problem, and does not pursue goals of its own. Skill on one task is not the same as the broader properties we usually mean by intelligence.
- In the
LearningFancode, what is the "rule for changing the rule"?Show answer
The
feedbackmethod: a "too hot" complaint lowers the threshold by 0.5 °C and a "too cold" complaint raises it by 0.5 °C. The threshold is the rule;feedbackchanges it. - Why did memory not help at all when the season flipped at random every day?
Show answer
Because the past then carries no information about today's season. Memory helps only by revealing something about a hidden condition that lasts. If the condition does not last, there is nothing for memory to reveal.
- Which of the four levels does each question belong to? (a) "What fraction of days did it get right?" (b) "Does the same principle explain how doctors use patient histories?" (c) "It counts rainy days in the last week." (d) "It works because seasons persist."
Show answer
(a) Measurement. (b) Generalisation. (c) Mechanism. (d) Theory.
- A friend says: "The experiment proves memory is the key to intelligence." What label would you give that claim, and what would you say?
Show answer
At best a working hypothesis, and a much broader one than the experiment tested. The experiment shows that, in one small simulated world, memory helps when a hidden condition lasts. It says nothing yet about other systems or about intelligence in general.
·Seminar exercises
Bring written answers. For each coding exercise, write your prediction before you run the code.
- Argue about Table 1. Pick two entries you disagree with. Change them, and justify each change with one concrete example of the system's behaviour.
- Test the surprise. Modify
scoreso that it reports accuracy only on the first 10 days after each season switch. (Hint:simulatewill need to return the season too.) Compare k = 7 and k = 14. Does the "slow to notice a switch" explanation hold up? - Change the world. Set the season persistence to 0.9 (seasons last about 10 days) and rerun. Before running, predict which memory length will do best and why. Were you right?
- Count the cost. Suppose getting soaked costs 3 and carrying the umbrella for nothing costs 1. Change the decision rule so that it minimises expected cost instead of maximising accuracy. (Hint: the threshold 0.5 should change. To what?)
·Readings
- Core. Turing, A. M. (1950). Computing machinery and intelligence. Mind, 59(236). Read sections 1, 2 and 6. Which of the objections in section 6 do you find strongest?
- Core. Chollet, F. (2019). On the measure of intelligence. arXiv:1911.01547. Read Part I. What is the difference between skill and intelligence in his account?
- Further. Legg, S., & Hutter, M. (2007). Universal intelligence: A definition of machine intelligence. Minds and Machines, 17(4). Read the introduction and the informal definition; the formula can wait.