How Machine Learning Works
Module 2 · Without the Math
Builds on: Module 1 (What Is AI?)
After completing this module, you will be able to:
- Explain how machine learning differs from traditional programming — in one sentence
- Describe the three types of machine learning with real examples
- Walk through how a model learns: training, validation, and testing
- Explain what a neural network does without using a single equation
- Describe the data pipeline from collection to deployment
- Identify where bias enters machine learning systems — and why it’s hard to remove
- Critically evaluate AI outputs by understanding what the model learned from
The Algorithm That Learned to Be Sexist
In 2018, Reuters broke a story that stunned the tech world. Amazon had built a machine learning system to automate hiring — scan resumes, score candidates, surface the best ones. The model trained on ten years of Amazon’s hiring data to learn what a “good” resume looked like.
It worked beautifully. The scores were consistent. The system was fast. There was just one problem: the model had taught itself to penalize women.
Because Amazon’s tech workforce had been predominantly male for a decade, the model learned that “male” was a feature of successful candidates. It downgraded resumes that contained the word “women’s” — as in “women’s chess club” or “captain of the women’s soccer team.” It penalized graduates of two all-women’s colleges. It had learned, with mathematical precision, to replicate a decade of human bias.
Amazon scrapped the tool. But the lesson endures: machine learning doesn’t discover truth. It discovers patterns in data. If the data contains bias, the model learns bias — and serves it back to you with the authority of mathematics.
This module teaches you how machine learning actually works — not the equations, but the ideas.
The Big Idea: Learning from Data Instead of Following Rules
Traditional programming: Humans write rules → computer follows them. Machine learning: Humans provide data → computer discovers the rules.
Imagine you want to teach someone to recognize spam emails.
The traditional approach: You write a list of rules. If the subject line contains “FREE MONEY,” it’s spam. If there are more than three exclamation marks, it’s spam. You write hundreds of rules, maintain the list forever. Spammers adapt, you write more rules.
The machine learning approach: You collect 100,000 emails — 50,000 spam, 50,000 not spam — and show them to the algorithm. You say: “Figure out what makes spam different from real email.” The algorithm examines every email, looking for patterns that distinguish the two categories. It discovers its own rules.
The second approach is how your email’s spam filter actually works. Nobody writes spam rules by hand anymore.
- “ML is magic” — It’s math. Specifically, it’s optimization: adjusting numbers to minimize prediction errors. No magic, no consciousness, no understanding.
- “More data always = better” — More representative data helps. More biased data just produces a more confidently biased model.
- “ML is objective” — ML finds patterns in data. If the data reflects human decisions (hiring, lending, policing), the model inherits human biases — and scales them.
- “The algorithm is neutral” — Choosing what to predict, what data to collect, and how to measure success are all human decisions that shape the outcome before the algorithm runs.
- “ML will figure it out” — ML needs human oversight at every stage: data selection, feature engineering, model evaluation, deployment monitoring, and ethical review.
ML in YOUR Field — Real Examples
- Supervised: Predicting hospital readmission risk from patient records (labeled: readmitted / not readmitted)
- Unsupervised: Discovering patient subgroups with similar symptom patterns for personalized treatment
- Reinforcement: Optimizing drug dosing schedules by learning from patient response data over time
- Supervised: Predicting customer churn from purchase history (labeled: churned / retained)
- Unsupervised: Segmenting customers by behavior to target marketing campaigns
- Reinforcement: Dynamic pricing that adjusts in real-time based on demand signals
- Supervised: Predicting which students are at risk of failing based on engagement data (labeled: passed / failed)
- Unsupervised: Discovering common misconception patterns across thousands of student responses
- Reinforcement: Adaptive learning systems that adjust difficulty based on student performance
- Supervised: Classifying crop diseases from photos (labeled: healthy / diseased / specific disease type)
- Unsupervised: Identifying zones within a field that have similar soil characteristics for variable-rate treatment
- Reinforcement: Optimizing irrigation scheduling by learning from soil moisture sensors and weather data
The Three Flavors of Machine Learning
1. Supervised Learning: “Here’s the Answer Key”
You give the algorithm labeled examples — data with the correct answer — and it learns to predict answers for new data.
Real-world examples: Email spam detection (labeled “spam” or “not spam”), medical diagnosis (X-rays labeled “tumor” or “no tumor”), language translation (sentence pairs in two languages).
2. Unsupervised Learning: “Find the Patterns”
No labels. You give the algorithm raw data and say: “Find the structure.” It discovers groupings humans might not see.
Real-world examples: Customer segmentation, anomaly detection (finding cyberattacks), topic modeling across thousands of documents.
3. Reinforcement Learning: “Trial, Error, Reward”
The algorithm learns by doing — taking actions, receiving rewards or penalties, and adjusting strategy.
Real-world examples: AlphaGo beating the world Go champion, self-driving cars, TikTok’s algorithm learning what keeps you scrolling.
Identify the ML type for each scenario:
- A hospital predicts readmission risk using labeled patient records.
- A retailer discovers product groupings from purchase data.
- A chatbot improves via customer satisfaction ratings.
- A bank detects fraudulent transactions.
Click to check your answers
- Supervised — labels exist (readmitted vs not).
- Unsupervised — no predefined categories.
- Reinforcement — actions + rewards.
- Could be unsupervised (anomaly detection) or supervised (labeled fraud examples). Most systems use a hybrid.
How a Model Learns: The Training Pipeline
Here’s the full process from raw data to deployed model:
RAW DATA → Clean & Label → Split (Train/Validate/Test)
↓
TRAINING LOOP:
Predict → Compare → Adjust → Repeat
(millions of iterations)
↓
Validate → Tune → Test on unseen data
↓
DEPLOY → Monitor for drift → Retrain
Step 1: Collect Data
Everything starts with data. This is where most problems begin. If data is biased, the model learns bias. Amazon’s hiring tool learned from biased data and produced biased outputs.
Step 2: Prepare and Split the Data
Data is cleaned and split into three sets:
- Training set (~70-80%): What the model learns from
- Validation set (~10-15%): Checks learning during training
- Test set (~10-15%): Final evaluation on unseen data
Why split? Because memorization is not learning. A student who memorizes last year’s answer key fails when the professor writes new questions.
Step 3: Train the Model
The model processes training data in an optimization loop: predict → compare → adjust → repeat. Millions of times.
Step 4: Validate and Tune
If the model performs well on training data but poorly on validation data, it’s overfitting: memorizing rather than learning.
If it performs poorly on both, it’s underfitting: it hasn’t learned enough.
- Overfitting: Performs perfectly on training data, fails on new data. Learned the noise, not the signal.
- Underfitting: Performs poorly on everything. Hasn’t captured the patterns.
- Just right: Performs well on both known and unknown data. Learned the patterns, not the specific examples.
Concrete example: You’re building a model to predict house prices. It trains on 10,000 homes in one city. An overfit model memorizes that “houses on Elm Street sell for $400K” — it learned specific addresses, not the pattern (square footage + bedrooms + neighborhood quality → price). When tested on homes in a different city, it’s useless. An underfit model just predicts “every house costs $300K.” The right model learns that bigger homes in better neighborhoods cost more — a pattern that transfers to ANY city.
Step 5: Test and Evaluate
Final evaluation on data the model has never seen. The closest simulation of real-world performance.
Step 6: Deploy and Monitor
The model goes live — but real-world data changes over time (data drift). A model that worked in January might fail in June. A spam filter trained in 2023 may miss 2026’s spam tactics. Ongoing monitoring is essential.
- Why is data split into three sets? (Training = learn, Validation = check during training, Test = final evaluation on unseen data)
- What’s overfitting? (Memorizing training data rather than learning general patterns — performs well on training data, poorly on new data)
- What’s the #1 law of machine learning? (Garbage in, garbage out — the model is only as good as its data)
- A house price model that only works in the city it was trained on is an example of: (Overfitting — it memorized specific data instead of learning transferable patterns)
Neural Networks: A Simple Explanation
The Building Block: A Single Neuron
A neuron takes in numbers, multiplies each by a weight (how important that input is), adds them up, and passes the result through a function that decides whether to “fire.” One neuron is useless. Millions connected in layers learn extraordinarily complex patterns.
A concrete forward pass: Imagine a single neuron deciding if an email is spam. It receives three inputs: (1) number of exclamation marks = 5, (2) contains “FREE” = 1 (yes), (3) from known sender = 0 (no). Each input has a learned weight: exclamation marks × 0.3 = 1.5, contains FREE × 0.8 = 0.8, known sender × (-1.0) = 0.0. Sum = 2.3. If the threshold is 1.5, the neuron fires: spam. The weights were learned during training — adjusted millions of times until the neuron got good at catching spam without flagging real emails.
The Data Pipeline: Where Everything Begins
COLLECT → CLEAN → LABEL → TRAIN → EVALUATE → DEPLOY → MONITOR
Where Bias Enters the Pipeline
| Stage | How Bias Enters | Example |
|---|---|---|
| Collection | Data doesn’t represent the full population | Medical AI trained mostly on white patients |
| Cleaning | Removing “outliers” that are underrepresented groups | Dropping non-English name applications |
| Labeling | Human labelers bring their own biases | Professional women labeled “receptionist” |
| Training | Model optimizes for the majority pattern | Amazon: “male” = “successful” |
| Evaluation | Test set has the same biases as training set | Model looks great — same blind spots |
| Deployment | Applied to populations it wasn’t trained on | US facial recognition deployed in Africa |
Garbage in, garbage out. A model is only as good as its data. If the data reflects historical biases, the model reproduces them — often more efficiently and at greater scale than humans.
A company builds an ML model to predict which job applicants will be “successful employees” based on 5 years of performance review data. Identify the bias risk at each stage:
- Data: What’s likely in 5 years of performance reviews? (Think: who does the reviewing?)
- Labels: How is “successful” defined? (Revenue generated? Manager ratings? Tenure?)
- Features: Which input variables might be proxies for protected characteristics?
- Evaluation: If the test set has the same biases as the training set, will you even detect the problem?
- Deployment: What happens when the model is applied to applicants from backgrounds underrepresented in the training data?
Key risks
- Data: Performance reviews carry well-documented biases — studies show women and minorities receive more subjective criticism and less credit for collaborative work.
- Labels: If “successful” means “high manager rating,” the model learns what managers reward — which may reflect bias, not performance. If it means “stayed 3+ years,” it penalizes people who were underpaid and left for better opportunities.
- Features: Zip code, university name, extracurricular activities, and even name formatting can be proxies for race, socioeconomic status, and national origin.
- Evaluation: Yes — this is the insidious part. If your test set has the same biases, the model looks great on paper while systematically discriminating.
- Deployment: The model will score these applicants as “low probability of success” because it has few examples of people like them succeeding — creating a self-fulfilling prophecy.
Evaluating AI Outputs: Five Questions to Always Ask
- What data was it trained on? (Who collected it? What’s missing?)
- What was it optimized for? (Accuracy? Engagement? Profit?)
- Who validated it? (Diverse populations? Diverse teams?)
- What are its known failure modes?
- Who benefits and who’s harmed?
Module 2 Summary
- Machine learning is learning from data, not following rules.
- Three types: Supervised, Unsupervised, Reinforcement.
- The training process splits data and iterates until the model generalizes well.
- Neural networks are layers of simple operations. Deep learning = many layers.
- Overfitting is memorization, not learning. The Goldilocks problem.
- Bias enters at every stage of the data pipeline.
- “Garbage in, garbage out” — the data shapes the model.
- Always ask: What data? What optimization? Who validated? Who benefits?
Machine learning doesn’t discover truth — it discovers patterns in data. And data is collected by humans, labeled by humans, and reflects human decisions about what to include and what to leave out. When an AI system discriminates, the tempting response is to blame the algorithm. But the algorithm did exactly what it was designed to do: find patterns in the data it was given. The real question isn’t “why is the AI biased?” The real question is “why is the data biased?” — and that’s a human question, not a technical one.
🔬 Lab 2: The Bias Detective
Lab 2: The Bias Detective
Time: 45 minutes | Tools needed: Any AI chatbot + browser
Part A — The Hiring Algorithm (15 min) Ask your AI chatbot: “I’m building a hiring algorithm for a tech company using 10 years of employee data. Walk me through how I’d train a model, then identify at least 5 places where bias could enter.” Compare its answer to the table in this module.
Part B — The Image Test (15 min) Ask your AI to describe: “a typical CEO,” “a typical nurse,” “a typical engineer,” “a typical teacher.” What gender, age, and race does it default to? What does this reveal about training data?
Part C — Reflection (15 min) Write 4-5 sentences: Where does bias come from? Is unbiased AI possible? What responsibility do AI users have?
Submit: Chatbot responses + reflection.
🎮 Module 2 Quiz
Previous: Module 01 — What Is AI? | Next: Module 03 — LLMs and Generative AI