How Does AI Learn?
Introduction
Section titled “Introduction”🎯 Learning goals
- Understand the difference between traditional programming and machine learning
- Know how AI is “trained” rather than “programmed”
- Understand the basic principle behind neural networks
- Know why data is critical to AI performance
To understand how AI works, we need to start with how traditional computer programs work — and why machine learning is something fundamentally different.
Traditional programming and machine learning are built on completely different principles. That difference determines which problems can even be solved with the help of computers.
From rules to examples: A fundamental difference
Traditional programming
Section titled “Traditional programming”A programmer writes exact instructions:
IF temperature is above 25 degrees Show "It's warm outside"IF temperature is between 15–25 degrees Show "It's pleasant outside"IF temperature is below 15 degrees Show "It's cold outside"Every rule, every scenario must be defined in advance. This works great for tasks with clear rules.
But some tasks can’t be programmed with rules
Section titled “But some tasks can’t be programmed with rules”Try writing exact rules for:
- Recognizing a cat in a picture (does it have fur? Pointed ears? But other animals have those too…)
- Deciding whether a text is positive or negative (irony complicates everything…)
- Deciding whether someone is angry, happy, or sad based on their voice
There’s no simple rule that always works — too many variations, too many nuances. That’s where machine learning comes in.
Instead of trying to write rules, we give the AI system thousands or millions of examples — and let it discover the patterns itself.
Machine learning: Learning from examples instead of rules
Example: Recognizing cats
Section titled “Example: Recognizing cats”Traditional programming (essentially impossible): “A cat has four legs, pointed ears, whiskers…” — But how do you code “cute”? How do you distinguish a cat from a fox?
Machine learning:
- Give the AI 100,000 images of cats (labeled “cat”)
- Give the AI 100,000 images of other animals (labeled “not cat”)
- Let the system find patterns in the pixels that distinguish cats from other animals
- Test with new images the system has never seen — it recognizes cats with high precision
No human has written any rules. The AI has discovered the patterns itself through examples.
How does the training process work in practice? Here we walk through it step by step with an everyday example.
How training works: A concrete example
Task: Train an AI to distinguish spam emails from legitimate ones.
Step 1: Collect data
Section titled “Step 1: Collect data”We collect 10,000 emails, of which 5,000 are spam and 5,000 are legitimate. Each email is labeled — this is called labeled data.
Step 2: The AI finds patterns
Section titled “Step 2: The AI finds patterns”The system analyzes the emails and discovers patterns:
- Spam often contains the words “free,” “win,” “click here”
- Spam has more frequent spelling errors
- Spam more often comes from unknown senders
- Legitimate emails often include your name in the greeting
The AI creates a mathematical model based on these patterns.
Step 3: Test on new emails
Section titled “Step 3: Test on new emails”We give the AI emails it has never seen before. It uses its model to guess: spam or not spam?
Step 4: Improve the model
Section titled “Step 4: Improve the model”If the AI guesses wrong, the model is adjusted. This is repeated until the AI is good enough.
Result: An AI that can classify new emails without anyone writing rules like “if the email contains the word ‘free,’ mark as spam.”
The most powerful type of machine learning uses neural networks — loosely inspired by how the brain works.
Neural networks: Inspiration from the brain
How does the brain work?
Section titled “How does the brain work?”Your brain contains billions of nerve cells (neurons) connected to each other. When you see a cat, certain neurons send signals to each other, and together they form the pattern “cat.” The more you see cats, the stronger those connections become.
Artificial neural networks do something similar — the system consists of layers of artificial “neurons” (mathematical functions) connected to each other.
Simplified example — image recognition:
Section titled “Simplified example — image recognition:”- First layer: Recognizes simple details (edges, lines, color differences)
- Second layer: Combines these into shapes (circles, triangles)
- Third layer: Combines shapes into parts (ears, nose, paw)
- Final layer: Combines parts into objects (“this is a cat”)
Each layer learns increasingly complex patterns by combining the results from the layer before it.
Deep neural networks have many layers (hence “deep” learning). This lets them learn extremely complex patterns.
Perhaps the most important insight about machine learning isn’t about algorithms or hardware — it’s about data.
Data is the key – Garbage in, garbage out
An AI is only as good as the data it was trained on.
- If you train an AI to recognize dogs but only show it pictures of golden retrievers, it may not recognize a dachshund or a German shepherd
- If you train an AI on texts full of errors, it will learn to write incorrectly
- If you train an AI on biased data, the AI will learn those biases
Real-world examples:
Section titled “Real-world examples:”- An AI for job applications trained on historical data (where most managers were men) learned to discriminate against female applicants
- An AI trained to recognize faces in pictures of mostly light-skinned people performed worse on people with darker skin
- An AI trained on medical studies with mostly male participants became worse at diagnosing women’s diseases
This isn’t because the AI is “evil” — it just learns patterns from the data. If the data is skewed, the AI is skewed. This is called bias and is one of AI’s biggest problems.
Machine learning is not a single technique — there are different approaches depending on the type of problem being solved.
Three types of machine learning
Supervised learning
Section titled “Supervised learning”The AI learns from examples with correct answers.
- Give it 10,000 images labeled “cat” or “dog”
- It learns the difference and can then classify new images
Used for: Image recognition, spam filters, diagnostic support
Unsupervised learning
Section titled “Unsupervised learning”The AI gets data without answers and finds patterns on its own.
- Give it 10,000 customer profiles without labels
- It finds groups of similar customers — segments you may not have known existed
Used for: Finding patterns, customer segmentation, anomaly detection
Reinforcement learning
Section titled “Reinforcement learning”The AI learns by trying things and receiving feedback — like training a dog.
- The system tries different things
- Gets a “reward” for good choices, a “penalty” for bad ones
- Learns which actions lead to the best results
Used for: Game AI, robotics, self-driving cars
Key takeaways
Section titled “Key takeaways”Here we gather the most important insights from this section before you move on to the quiz.
- Traditional programming relies on exact rules. Machine learning lets AI learn patterns from examples instead
- AI is trained by receiving thousands or millions of examples and finding statistical patterns — no one writes the rules, the system discovers them itself
- Neural networks are inspired by the brain and consist of layers that learn increasingly complex patterns. Deep learning means many layers and the ability to learn extremely complex relationships
- Data is critical: an AI is only as good as the data it was trained on — bad or biased data gives bad or biased AI (bias)
Test your knowledge
4 questions · 100% correct to pass · Review your answers when done