Lesson 1 Β· The basic idea

πŸ€– What Machine Learning Actually Is

Machine learning is often described in hype, but the core idea is simple: instead of hand-writing rules for every case, a model learns a pattern from examples, and generalizes that pattern to new, unseen cases.

πŸ€– Learning rules from examples, not writing them by hand

Traditional programming: a human writes explicit rules ("if income > $50k and age > 25, approve"). Machine learning: a model is shown many labeled examples (past approved/rejected applications) and learns the pattern itself β€” useful exactly when the real rule is too complex or unknown to write by hand.

Traditional: if (email.endsWith("@company.com")) { allow(); } // a rule a human wrote ML: show the model 10,000 past emails labeled "spam"/"not spam", let it learn the pattern itself

🖼️ See it

Traditional rules vs machine learningTraditional rulesA human writes explicit logicWorks well when rules are knownand simpleBrittle when the real pattern iscomplexMachine learningA model learns the pattern fromexamplesWorks well when the rule is toocomplex to write by handNeeds enough representative datato learn from

🖼️ See it

Types of learningTypeLearns fromExampleSupervisedLabeled input→outputpairsSpam detectionUnsupervisedUnlabeled data, findsstructureCustomer groupingReinforcementTrial, error, andrewardA game-playing agent

🎯 Supervised, unsupervised, and reinforcement learning

Supervised learning learns from labeled examples (input β†’ known correct output) β€” like spam detection. Unsupervised learning finds structure in unlabeled data (like grouping similar customers together with no predefined groups given). Reinforcement learning learns by trial and error, optimizing for a reward signal over many attempts (like a game-playing agent).

πŸ“Š Classification vs regression

Within supervised learning, classification predicts a category ("spam" or "not spam"; "cat", "dog", or "other"), while regression predicts a continuous number (a house's price, tomorrow's temperature). The right choice of problem type shapes everything downstream β€” the model architecture, the metric used to judge it, and more.

Common mistake. Treating a problem that is really regression (predicting an exact price) as classification (bucketing into "cheap/medium/expensive") when a precise number is actually needed, losing useful precision.

πŸͺœ Step by step: framing an ML problem

Decide the learning type, the target and whether it is classification or regression.

Problem: A bank wants to (a) flag likely fraudulent card payments and (b) predict next month’s spending per customer. Frame each.

  1. (a) Target.
    fraud yes/no β†’ classification
  2. (a) Data.
    past payments with fraud labels β†’ supervised
  3. (b) Target.
    an amount in dollars β†’ regression
  4. Is ML needed? Check simple rules first (e.g. "payment > 10Γ— usual"). Use ML if rules miss too much.

Answer: (a) supervised classification, (b) supervised regression.

Common mistake: calling fraud detection regression because the payment has an amount.
✏️ Quick check · 1 of 8
ML vs rules

Machine learning is most useful compared to hand-written rules when:

When does learning a pattern from examples make more sense than writing the rule directly?
✏️ Quick check · 2 of 8
Learning types

A spam filter trained on emails that are each already labeled "spam" or "not spam" is an example of:

Does this setup use labeled data, unlabeled data, or trial-and-error with rewards?
✏️ Quick check · 3 of 8
Learning types

Grouping customers into segments with no predefined categories, based purely on patterns in unlabeled purchase data, is an example of:

Are there predefined correct labels to learn from here, or is the model finding its own structure?
✏️ Quick check · 4 of 8
Learning types

An agent that learns to play a game well purely through repeated attempts and a reward signal (points scored) is an example of:

Is this agent learning from labeled examples, or from trial-and-error guided by a reward?
✏️ Quick check · 5 of 8
Classification vs regression

Predicting whether an email is "spam" or "not spam" is an example of:

Is the output here a category, or a continuous number?
✏️ Quick check · 6 of 8
Classification vs regression

Predicting the exact price a house will sell for is an example of:

Is the output here a category, or a continuous number?
✍️ Type your answer · 7 of 8

A dataset of 10,000 labeled emails is used to train a spam classifier, with 2,500 labeled "spam" and the rest "not spam."

How many of the 10,000 emails are labeled "not spam"?

Enter a whole number.
Subtract the spam-labeled emails from the total emails.
✍️ Type your answer · 8 of 8

A reinforcement learning agent plays 500 training games, winning 180 of them.

What percentage of the 500 training games did the agent win?

Enter a number, such as 24 or 200.
Divide the wins by the total games, times 100.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5

Machine learning is most useful compared to hand-written rules when:

Question 2 of 5

A spam filter trained on emails already labeled "spam"/"not spam" is:

Question 3 of 5

Grouping customers with no predefined categories from unlabeled data is:

Question 4 of 5

Learning to play a game via trial, error, and reward is:

Question 5 of 5

Predicting the exact price a house will sell for is: