AI, Machine Learning & Deep Learning

How the buzzwords relate: AI contains machine learning, which contains deep learning.

These three terms are nested circles, from broadest to narrowest.

TermMeaning
AIAny technique that makes machines act intelligently.
Machine Learning (ML)Programs that learn patterns from data instead of being hand-coded with rules.
Deep LearningML using large neural networks with many layers. LLMs live here.

Training vs. inference

  • Training — the slow, expensive process of learning patterns from huge datasets. Done once by model providers.
  • Inference — using the trained model to answer a request. This is what your API call triggers, and what you pay for.

Example

Example · json
{
  "AI": {
    "Machine Learning": {
      "Deep Learning": ["Large Language Models", "image models", "speech models"]
    }
  }
}

When to use it

  • A fraud-detection team uses a traditional ML model (gradient boosting) because interpretability matters for compliance audits.
  • A computer-vision startup uses deep learning CNNs to detect cracks in bridge photos where hand-crafted features would miss subtle patterns.
  • A data scientist chooses a shallow ML pipeline for a tabular churn dataset because it trains in seconds with only 10k rows.

More examples

Scikit-learn logistic regression

Classic ML: trains logistic regression on tabular features without any neural network.

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)
model.fit(X, y)
print('Accuracy:', model.score(X, y))

PyTorch two-layer neural network

Defines a small deep-learning network in PyTorch showing the stack of layers that characterises DL.

Example · python
import torch.nn as nn

net = nn.Sequential(
    nn.Linear(4, 16),
    nn.ReLU(),
    nn.Linear(16, 3)
)
print(net)

Rule-based AI vs LLM comparison

Contrasts a hand-coded rule-based system with a learned LLM approach for the same task.

Example · python
# Rule-based AI (explicit if/else)
def rule_ai(text):
    return 'positive' if 'good' in text.lower() else 'negative'

# LLM AI (learned from data)
from openai import OpenAI
client = OpenAI()
def llm_ai(text):
    r = client.chat.completions.create(
        model='gpt-4o-mini',
        messages=[{'role':'user','content':f'Sentiment (one word): {text}'}]
    )
    return r.choices[0].message.content

print(rule_ai('This is good!'))  # positive
print(llm_ai('This is good!'))   # positive

Discussion

  • Be the first to comment on this lesson.