How Machines Learn
From the course Introduction to AI: Core Concepts
Machine learning is the process of teaching computers to recognize patterns in data. Instead of programming explicit rules ("if email contains 'free money,' mark as spam"), you show the machine thousands of examples and let it discover the patterns itself.
The Three Types of Machine Learning
1. Supervised Learning
You give the model labeled examples — inputs paired with correct outputs:
- 10,000 photos labeled "cat" or "dog" → Model learns to classify new photos
- 1 million emails labeled "spam" or "not spam" → Model learns to filter email
- Historical house prices with features (size, location, age) → Model learns to predict prices
This is the most common type. You need labeled data, which can be expensive to create.
2. Unsupervised Learning
You give the model data without labels and ask it to find structure:
- Customer purchase data → Model discovers customer segments
- Text documents → Model finds topic clusters
- Network traffic → Model identifies unusual patterns (anomaly detection)
No labels needed, but results require human interpretation.
3. Reinforcement Learning
The model learns by trial and error, receiving rewards for good actions:
- A game-playing AI gets +1 for winning, -1 for losing
- A robot learning to walk gets rewards for staying upright
- ChatGPT was fine-tuned with RLHF (Reinforcement Learning from Human Feedback) — human raters scored responses, and the model learned to generate preferred answers
The Training Process (Simplified)
- Gather data — Collect thousands to billions of examples
- Choose a model architecture — Neural network, transformer, etc.
- Initialize with random weights — The model starts knowing nothing
- Feed training data — Show examples one batch at a time
- Calculate error — How wrong was the prediction?
- Update weights — Adjust internal parameters to reduce error (backpropagation)
- Repeat — Millions or billions of times until error is minimized
- Evaluate — Test on data the model hasn't seen to check generalization
Overfitting & Underfitting
- Overfitting — The model memorizes training data but fails on new data (like a student who memorizes answers but can't solve new problems)
- Underfitting — The model is too simple to capture patterns (like trying to predict weather with only temperature)
Finding the sweet spot between these is a core challenge in machine learning.
Key Concept: Parameters
When you hear "GPT-4 has 1.7 trillion parameters" — parameters are the adjustable numbers inside the model that get tuned during training. More parameters generally means the model can capture more complex patterns, but also requires more data and computing power.
Key Takeaways
- •Supervised learning uses labeled data; unsupervised finds patterns without labels
- •Reinforcement learning teaches through rewards and penalties (used in RLHF for ChatGPT)
- •Training = showing examples, calculating errors, and adjusting weights millions of times
- •Parameters are the adjustable numbers inside a model — more means more capacity
- •Overfitting (memorization) vs underfitting (too simple) is a core ML challenge
Progress is kept in this browser only.