AI vs Machine Learning vs Deep Learning

Three nested ideas: AI is the goal, machine learning is an approach, deep learning is a technique.

These three terms are often mixed up. They are best seen as nested circles.

  • Artificial Intelligence (AI) — the broad goal of making machines act intelligently.
  • Machine Learning (ML) — a way to reach AI by learning patterns from data instead of hand-coding rules.
  • Deep Learning (DL) — a kind of ML that uses many-layered neural networks, great for images, audio and text.

Rules vs learning

Traditional programming: you write rules, the computer applies them. Machine learning: you show examples, the computer discovers the rules.

AI ⊃ ML ⊃ DL. Every deep-learning model is machine learning, but not every ML model is deep learning.

Example

Example · python
# Traditional rules vs learned rules (concept)

# Rules-based: a human writes the logic
def is_spam_rules(email):
    return 'free money' in email.lower()

# Machine learning: the model learns from labelled examples
# model.fit(emails, labels)   ->   model.predict(new_email)
print(is_spam_rules('Claim your FREE MONEY now'))  # True

When to use it

  • A product manager distinguishes AI (the goal), ML (learning from data), and deep learning (neural nets) when briefing stakeholders on a recommendation engine project.
  • An engineer chooses scikit-learn ML over PyTorch DL for a tabular dataset because deep learning is overkill for structured data with 10,000 rows.
  • A job listing specifies 'ML experience required, DL a plus', reflecting that deep learning is a specialised subset of the broader ML field.

More examples

Rule-based vs ML approach

Contrasts a hand-coded rule for spam detection with an ML model that learns equivalent rules automatically from labelled examples.

Example · python
# Traditional rule-based AI
def is_spam_rules(email):
    return 'win a prize' in email.lower()

# ML approach - model learns rules from labelled data
from sklearn.naive_bayes import MultinomialNB
# model = MultinomialNB().fit(X_train, y_train)

Classic ML: logistic regression

Fits a logistic regression classifier on the Iris dataset, representing the ML circle nested inside the broader AI goal.

Example · python
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)
model = LogisticRegression(max_iter=200).fit(X, y)
print(model.score(X, y))

Deep learning: two-layer neural net

Defines a two-layer neural network in PyTorch, showing the innermost circle: deep learning is a specific type of machine learning.

Example · python
import torch
import torch.nn as nn

net = nn.Sequential(
    nn.Linear(4, 16),
    nn.ReLU(),
    nn.Linear(16, 3)
)
x = torch.randn(1, 4)
print(net(x))

Discussion

  • Be the first to comment on this lesson.