Velamuvi AIAcademy

Lesson 2 of 13 · What Is ML?

AI vs ML vs Deep Learning

How AI, machine learning, deep learning and generative AI relate, with examples of each and hand-written rules compared with rules learned from data.

  • 5 min read
  • Beginner
  • Reviewed
In this lesson you will learn
  • Explain what AI, machine learning and deep learning each mean
  • Describe how they fit inside each other
  • Compare rules written by a person with rules learned from data
  • Place generative AI and chat assistants in the picture

Three terms, one family

People often use “AI”, “machine learning” and “deep learning” as if they meant the same thing. They are related, but each is a smaller circle inside the one before.

CircleExampleHow it works
AI (all of it)A chess program from the 1990sPeople wrote search rules and scoring formulas
Machine learningA bank's fraud detectorLearns from millions of past payments labelled fraud or genuine
Deep learningFace unlock on a phoneA neural network learned faces from huge numbers of images
Generative AIA chat assistantA very large deep learning model that learned to produce text

So all deep learning is machine learning, and all machine learning is AI, but not the other way round.

Rules written vs rules learned

The program below solves the same problem twice: spotting spam. The first filter uses rules a person wrote. The second learns which words matter by counting them in labelled examples:

Try it yourselfPython
# Approach 1: a person writes the rules (AI without machine learning)
def rule_based_is_spam(email):
    email = email.lower()
    return "free money" in email or "winner" in email or "click here" in email

# Approach 2: the computer learns which words matter from labelled examples
examples = [
    ("claim your free prize now", True),
    ("you are a winner claim your prize", True),
    ("cheap pills limited offer", True),
    ("limited offer claim cheap watches", True),
    ("lunch tomorrow at noon", False),
    ("the meeting notes are attached", False),
    ("can you review my report", False),
    ("notes from the team lunch", False),
]

spam_counts, ham_counts = {}, {}
for text, is_spam in examples:                       # training: count words in each group
    counts = spam_counts if is_spam else ham_counts
    for word in text.split():
        counts[word] = counts.get(word, 0) + 1

def learned_is_spam(email):
    score = 0
    for word in email.lower().split():
        score += spam_counts.get(word, 0) - ham_counts.get(word, 0)
    return score > 0

for email in ["Claim your cheap prize", "Team lunch notes", "WINNER! Click here"]:
    print(f"{email:<24} rules: {rule_based_is_spam(email)!s:<5}  learned: {learned_is_spam(email)}")

Each approach has a blind spot:

  • The written rules missed “Claim your cheap prize”, because nobody wrote a rule for “prize”.
  • The learned filter missed “WINNER! Click here”, because those words never appeared in its training examples.

The learned filter improves when you give it more examples; the rule-based one improves only when a person writes more rules. With millions of emails, learning wins easily, which is why real spam filters use machine learning.

Where generative AI fits

Chat assistants such as ChatGPT and Claude are large language models: deep learning models that learned to predict text. They sit in the smallest circle, but they rest on everything outside it: data, training, testing and the ideas you'll learn in this course.

Common mistakes

Practice exercise

In rule-based AI, a person keeps adding rules. Add one more rule to this spam filter.

Your solutionPython
def is_spam(email):
    email = email.lower()
    # Add a rule so that emails containing "prize" are also spam
    return "winner" in email

for email in ["You won a PRIZE", "Meeting at 3pm", "Winner announced"]:
    print(email, "->", is_spam(email))
Knowledge check

Which statement is true?

Summary

  • AI is the broad goal; machine learning learns from data; deep learning uses large neural networks; generative AI creates content.
  • Each is a smaller circle inside the one before.
  • Written rules need people to anticipate every case; learned rules improve with more data.
  • Pick the simplest approach that works: sometimes a written rule, often a simple model, sometimes deep learning.

Next: the main types of machine learning.

Finished reading? Tick it off to track your progress.