Session 2: How Machines Learn Without Going to School
Machine learning flips programming upside-down — instead of writing rules, you give data and let the computer figure it out.
The Part Where Computers Surprise You
Netflix knowing your taste, your bank catching fraud, your email filtering spam — nobody sat down and programmed explicit rules for each of these. They learned from data. Like how you learned a hot stove is bad, except they need about 10 million examples to get the point.
So, What Is Machine Learning?
Machine learning = computers that learn from data instead of being explicitly programmed.
Here's the difference:
- Traditional programming: Rules + Data → Answers ("if email contains 'Nigerian prince', mark spam")
- Machine learning: Data + Answers → Rules ("here are 10 million emails labeled spam or not — figure out the pattern yourself")
Key insight: nobody tells the machine what to look for. It discovers patterns on its own.
The Dog Training Analogy
Think of ML like training a dog:
- Show behavior (data)
- Dog tries something (prediction)
- Treat if right (feedback)
- Repeat
- Dog gets it (model)
Now do that a million times per second with a trillion examples. The dog doesn't understand why sitting earns a treat — just that sitting → treat. Similarly, an ML model doesn't understand spam — just that certain patterns → certain labels.
The Three Flavors of Machine Learning
1. Supervised Learning 🏷️ "Here's the textbook with the answer key"
- You give the model labeled examples. 10,000 cat photos + 10,000 dog photos, each labeled.
- Examples: spam filters, fraud detection, medical imaging, house price prediction.
- Analogy: studying with flashcards — you see the question and the answer together.
2. Unsupervised Learning 🔍 "Here's a pile of stuff — sort it however makes sense"
- Data without labels. The model finds hidden patterns on its own.
- Examples: customer segmentation, anomaly detection, recommendation engines.
- Analogy: a kid sorting a pile of mixed candy by color, shape, or size — nobody told them how to group it.
3. Reinforcement Learning 🎮 "Learn by trial and error — here's a score"
- An agent takes actions in an environment and learns from rewards and penalties.
- Examples: AlphaGo, self-driving cars, robot control, ad optimization.
- Analogy: learning to ride a bike — you fall, adjust, fall less, eventually balance.
How a Machine Actually Learns
The process in 6 steps:
- Gather data — lots of it
- Feed it to a model — the model makes predictions
- Model predicts — badly at first
- Check the error — how wrong was it?
- Adjust — tweak internal parameters to reduce error
- Repeat millions of times — until predictions get good
It's like tuning a radio dial — you turn it a tiny bit, check if the signal gets better, turn again, repeat until you lock in the station.
What Makes a Good (or Bad) Model?
- Overfitting: the model memorized the training data but fails on new data. Like memorizing a practice test word-for-word and bombing the real exam.
- Underfitting: the model is too simple to capture the actual patterns in the data.
- Biased data: if your training data has biases, the model inherits them — and automates discrimination at scale.
- Not enough data: ML models are data-hungry. They need lots of examples to generalize well.
Real-Life Examples You Already Use
| What You See | What's Happening |
|---|---|
| Amazon recommendations | ML clustering your purchase behavior |
| Phone face unlock | Trained on multiple angles of your face |
| Siri understanding your voice | Speech-to-text ML model |
| Google search ranking | ML ranking results by relevance |
| Instagram feed order | ML predicting what you'll engage with |
| Bank blocking a transaction | ML anomaly detection flagging fraud |
🧪 Try It Yourself: Watch ML Learn in Real Time
- Go to Teachable Machine
- Click Get Started → Image Project → Standard
- Class 1: hold up a pen — take 30+ webcam photos
- Class 2: show empty hand — take 30+ photos
- Click Train Model — watch it learn
- Test it: hold up the pen, remove it, see the predictions change in real time
What you just did: you created a supervised learning model. You gave it labeled data (pen vs. empty hand), it found patterns, and now it can classify new images.
Bonus Challenge
Add a 3rd class (like a mug or phone) and retrain. Notice how more classes require more data to stay accurate.
💡 Why This Matters
- Evaluate AI claims: What data was it trained on? How accurate is it really?
- Spot bad AI: Biased training data → biased results. Now you can call it out.
- Use ML tools: AutoML, SageMaker, no-code platforms let you build models without a PhD.
- Set right expectations: ML is pattern recognition, not magic. It's powerful but brittle.
📋 Quick Recap
- ML = computers that learn from data instead of hand-written rules
- Traditional programming: rules → answers. ML: data → rules
- Three types: supervised (labeled data), unsupervised (find patterns), reinforcement (trial & error)
- Models learn by predict → check → adjust, repeated millions of times
- Watch out for overfitting and biased data
- You already experience ML dozens of times daily
🎯 Fun Analogy to Remember
Machine learning is like teaching someone to cook by feeding them 10 million meals. Instead of giving them a recipe book (traditional programming), you give them every dish ever made and say "Figure out the patterns." They'll eventually know that garlic + butter = magic, even if they can't explain why. They'll nail most dishes — but occasionally they'll put ketchup on ice cream, fully convinced it's a great idea. That's called a hallucination, and we'll talk about those in Session 9.