Gradient LabStart the lesson

Lessons › Chapter 1: Foundations

What is machine learning?

A normal program is a recipe. You write the rules, the computer applies them to data and produces answers.

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Meet the team

Maya has just joined Brightbank, an online bank, to start its first machine learning team. Leo is the engineer. Her first question: what could a computer learn from all the bank’s data?

Concept

Programs follow rules

A normal program is a recipe. You write the rules, the computer applies them to data and produces answers.

Data goes in, rules do the work, answers come out.

Problem

Some rules are impossible to write

How would you write rules for spotting a cat in a photo, or spam that changes every day? The list of if… else if… never ends, and it breaks on new cases.

Key idea

Flip it around

Machine learning swaps the arrows. You give the computer data and the answers, and it works out the rules by itself. Those learned rules are called a model.

Traditional: data + rules → answers. Machine learning: data + answers → rules.

Concept

A model is a function

Once trained, a model works like a machine: put something in, get a guess out. Put in a house size, get back a price. Put in an email, get back “spam” or “not spam”. We call the input x and the guess ŷ (say “y-hat”).

Insight

Learning means getting less wrong

Learning is a loop: guess, see how wrong you were, adjust a little, repeat. One trip through all the examples is called an epoch. Watch the red error bar shrink.

Everything in this course is a variation on this loop.

Real life

In real life: your spam filter

Every email service runs a learned spam filter. Nobody writes a rule for every scam. The filter learned what junk looks like from millions of emails that people marked as spam, and it keeps learning as scams change.

Quick check: What does a machine learning model learn from?

Supervised models learn the rules from examples where the answer is already known.

Pseudocode

# Old way: a person writes the rules
rule: if email contains "free money"
    then mark it as spam

# Machine learning: the computer finds the rules
model = new empty model
model.learn(example emails, their right answers)
model.guess(new email)    # uses what it learned

Key terms

model
The thing that learns. After training it takes an input and gives back a guess.
epoch
One full pass through all the training examples.

Build it: Your first ML model: an iris flower classifier (20 min, runs in your browser)

See the project