ML Notes
Understand the differences and relationships between Artificial Intelligence, Machine Learning, and Deep Learning with clear examples, comparisons, and visual diagrams.
One of the most common confusions in the tech world is understanding how Artificial Intelligence, Machine Learning, and Deep Learning relate to each other. Let's break down these terms clearly so you never mix them up again.
The Nested Relationship
These three concepts are nested like Russian dolls — each is a subset of the one above it:
Artificial Intelligence (AI)
AI is the broadest concept — it refers to any system that can perform tasks that typically require human intelligence. This includes:
- Rule-based systems: Expert systems with hand-coded if-then rules
- Search algorithms: Chess engines that evaluate millions of positions
- Natural language processing: Chatbots and language translators
- Computer vision: Systems that understand images and video
- Robotics: Physical systems that interact with the environment
Example: A Simple Rule-Based AI
# Rule-based AI - no learning involved
def diagnose_symptom(temperature, cough, fatigue):
if temperature > 38.5 and cough and fatigue:
return "Possible flu - consult a doctor"
elif temperature > 37.5 and cough:
return "Possible cold - rest and hydrate"
elif fatigue and not cough:
return "Possible fatigue - get more sleep"
else:
return "Symptoms unclear - monitor and consult if persistent"
# This is AI but NOT machine learning - rules are manually coded
print(diagnose_symptom(39.0, True, True))Machine Learning (ML)
ML is a subset of AI where systems learn from data rather than being explicitly programmed. The key distinction is that ML algorithms improve their performance as they see more data.
Example: ML-Based Classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
# Load data
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
iris.data, iris.target, test_size=0.2, random_state=42
)
# The model LEARNS patterns from data
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)
print(f"Model learned to classify flowers with {accuracy:.1%} accuracy")
print("No rules were manually coded - the model discovered them!")Deep Learning (DL)
Deep learning is a subset of ML that uses neural networks with multiple layers (hence "deep"). These networks can automatically learn hierarchical representations from raw data.
Example: Deep Learning with TensorFlow
Detailed Comparison Table
| Aspect | AI | Machine Learning | Deep Learning |
|---|---|---|---|
| Scope | Broadest | Subset of AI | Subset of ML |
| Data needed | Minimal to none | Moderate | Massive |
| Feature engineering | Manual | Semi-manual | Automatic |
| Hardware | Standard CPU | CPU/GPU | GPU/TPU required |
| Interpretability | High | Medium | Low (black box) |
| Examples | Chess engine, Siri | Spam filter, Netflix | Self-driving cars, GPT |
| Training time | N/A | Minutes to hours | Hours to weeks |
| Accuracy | Rule-dependent | Good | Excellent (with enough data) |
When to Use What?
| ├── NO | Use rule-based AI or traditional ML with less data |
| ├── NO | Use traditional ML (Random Forest, SVM, etc.) |
| ├── NO | Use transfer learning or simpler models |
| └── YES | Use Deep Learning |
Performance vs Data Size
Python: Comparing Approaches on Same Problem
import numpy as np
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
# Load digit recognition dataset
digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(
digits.data, digits.target, test_size=0.2, random_state=42
)
# Traditional ML approach 1: Random Forest
rf = RandomForestClassifier(n_estimators=100, random_state=42)
rf.fit(X_train, y_train)
rf_acc = accuracy_score(y_test, rf.predict(X_test))
# Traditional ML approach 2: SVM
svm = SVC(kernel='rbf', random_state=42)
svm.fit(X_train, y_train)
svm_acc = accuracy_score(y_test, svm.predict(X_test))
print(f"Random Forest Accuracy: {rf_acc:.4f}")
print(f"SVM Accuracy: {svm_acc:.4f}")
print("\nFor this small dataset, traditional ML works great!")
print("Deep learning shines with much larger datasets (thousands+ images)")Real-World Examples by Category
Pure AI (Rule-based)
- Thermostat controllers
- Simple chatbots with decision trees
- Game AI in basic video games
Machine Learning
- Email spam filtering
- Product recommendation engines
- Credit card fraud detection
- Weather prediction models
Deep Learning
- Face recognition (FaceID)
- Voice assistants (Alexa, Siri)
- Self-driving cars
- Language translation (Google Translate)
- Image generation (DALL-E, Stable Diffusion)
Interview Questions
- What is the relationship between AI, ML, and DL?
DL is a subset of ML, which is a subset of AI. AI is the broadest concept of machines mimicking intelligence, ML learns from data, and DL uses multi-layer neural networks.
- When would you choose traditional ML over deep learning?
When you have limited data, need interpretability, have constrained compute resources, or the problem is relatively simple with well-defined features.
- Why does deep learning need more data than traditional ML?
Deep networks have millions of parameters to tune. Without sufficient data, they overfit. Traditional ML has fewer parameters and can work with smaller datasets.
- Can you name a task where rule-based AI still outperforms ML?
Mathematical computations, simple business rules (tax calculations), and deterministic systems where rules are clear and complete.
- What is feature engineering and why does deep learning reduce the need for it?
Feature engineering is manually creating input variables. Deep learning automatically learns relevant features through its multiple layers, reducing manual effort.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for AI vs ML vs Deep Learning — Machine Learning.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Machine Learning topic.
Search Terms
machine-learning, machine learning, machine, learning, introduction, deep, ai vs ml vs deep learning — machine learning
Related Machine Learning Topics