ML Chapter0
ML Chapter0
MACHINE LEARNING
A Complete Guide — From Zero to Understanding
CHAPTER 0
How Do Computers Actually "Think"?
Covering: Intelligence · AI vs ML vs DL · Real-World Applications · First Python Code
Page 1
Machine Learning — A Complete Guide | Chapter 0
📖 A Story First
Priya is a 10-year-old girl. One afternoon, her younger brother Arjun spills his glass
of milk on the floor. Priya has never been told what to do in this exact situation —
nobody gave her a step-by-step instruction manual. But she immediately does four
things:
This — the ability to learn from experience, adapt to new situations, and solve
problems without being explicitly told how — is the core of intelligence.
Intelligence =
The ability to acquire knowledge from experience,
reason about it, and apply it flexibly to new situations.
Page 2
Machine Learning — A Complete Guide | Chapter 0
💡 Key Insight
Notice that intelligence is NOT about being fast. A calculator is extremely fast — it can
do a million additions per second. But it has zero intelligence. Why? Because it cannot
learn from experience or adapt. It can only do exactly what it was told, every single
time.
Page 3
Machine Learning — A Complete Guide | Chapter 0
Here is something surprising: Computers are both smarter AND dumber than humans —
depending on the task. A laptop can multiply two 20-digit numbers in a nanosecond. But it
would completely fail to understand that 'it is raining cats and dogs' does not mean actual
animals are falling from the sky. Humans understand context, metaphor, and nuance
effortlessly. Machines still struggle with these enormously.
Page 4
Machine Learning — A Complete Guide | Chapter 0
Think of it like an onion with three layers, where each inner layer is a more specific
version of the outer one:
╔═════════════════════════════════════════════════════════════════
═╗
║
║
║ ARTIFICIAL INTELLIGENCE (AI) ─── The big idea
║
║ Any technique that lets machines mimic human intelligence
║
║
║
║ ┌──────────────────────────────────────────────────────┐
║
║ │ │
║
║ │ MACHINE LEARNING (ML) ─── A smarter method │
║
║ │ Systems that learn from data automatically │
║
║ │ │
║
║ │ ┌──────────────────────────────────────────┐ │
║
║ │ │ │ │
║
║ │ │ DEEP LEARNING (DL) ─── The powerhouse │ │
║
║ │ │ ML using many-layered neural networks │ │
║
║ │ │ │ │
║
║ │ └──────────────────────────────────────────┘ │
║
║ └──────────────────────────────────────────────────────┘
║
║
Page 5
Machine Learning — A Complete Guide | Chapter 0
╚═════════════════════════════════════════════════════════════════
═╝
Everything inside is a subset of everything outside. All Deep Learning is Machine Learning. All
Machine Learning is AI. But not all AI is Machine Learning, and not all ML is Deep Learning.
The idea is not new. The term 'Artificial Intelligence' was coined in 1956 by John McCarthy at a
conference at Dartmouth College. Early AI approaches were rule-based — programmers
manually wrote every single rule the computer should follow.
Old chess programs like Deep Blue worked by brute force rules:
• 'If your rook is on the same column as the opponent's king, check if the path is clear.'
• 'If the opponent's queen is threatening your knight, move the knight.'
• ...and thousands more such rules, all hand-coded by programmers.
This IS artificial intelligence. But it is NOT machine learning — because the program
learned nothing from experience. Every rule was written by a human, manually.
Page 6
Machine Learning — A Complete Guide | Chapter 0
The fundamental shift of Machine Learning is this: instead of telling the computer
WHAT to do, we show it EXAMPLES of what good answers look like, and the computer
figures out the pattern on its own. This is exactly how human children learn — not by
reading rule books, but by experiencing the world.
In return, Deep Learning can solve problems that ordinary ML cannot — like recognising faces
in photos with 99% accuracy, translating languages in real-time, generating human-like text
(like ChatGPT), or detecting cancer in X-rays better than doctors.
Page 7
Machine Learning — A Complete Guide | Chapter 0
Page 8
Machine Learning — A Complete Guide | Chapter 0
YEAR EVENT
SIGNIFICANCE
──────
─────────────────────────────────────────────────────────────
──────────────
1950 Alan Turing proposes the 'Turing Test'
AI is born as an idea
1956 'AI' coined at Dartmouth Conference
Official birth of the field
1960s First neural networks (Perceptron) created
Early DL ancestor
1980s Expert Systems rule AI — hand-coded rules everywhere
AI 'winter' approaches
1986 Backpropagation algorithm invented
Neural nets can now learn!
1997 Deep Blue beats world chess champion Kasparov
Milestone for game AI
2006 Geoffrey Hinton revives deep neural networks
Deep Learning is born
2012 AlexNet wins ImageNet — deep learning beats everything
ImageNet Revolution
2016 AlphaGo beats world Go champion
Deep RL milestone
2017 'Attention is All You Need' paper — Transformer invented
Foundation of ChatGPT
2020 GPT-3 released — AI can write like humans
NLP revolution
2022 ChatGPT launches — 100M users in 60 days
AI goes mainstream
2024 Multimodal AI (text+image+audio) — AI sees, hears,
speaks Where we are today
Page 9
Machine Learning — A Complete Guide | Chapter 0
Computers do NOT think. Not really. They do not have consciousness, opinions, feelings, or
desires. What they do have is an extraordinary ability to find patterns in numbers — and that
turns out to be enough to simulate thinking, to a remarkable degree.
Everything in the world — every image, every sound, every word, every
temperature reading — can be converted into numbers. And once you have
numbers, you can find patterns. And once you find patterns, you can make
predictions. This is the entire foundation of Machine Learning.
🎯 Aha Moment
This is why Machine Learning can work on seemingly unrelated things — spam emails,
cancer detection, music recommendations — using the same core algorithms. They all
Page 10
Machine Learning — A Complete Guide | Chapter 0
A new house of 175 sq. metres comes on the market. What should it sell for?
You could eyeball the table and guess somewhere around ₹90 lakhs. That is actually your
brain doing informal ML — finding a pattern (bigger house → higher price) and extrapolating.
A machine would do this more formally. Let us plot these points and draw a line through them:
Price
(₹L) │ *
104
│ .
80 ──┤ * 78
│ .
60 ──┤ * 63
│ * 52
40 ──┤ * 41
│
Page 11
Machine Learning — A Complete Guide | Chapter 0
20 ──┤ * 25
│
0 ──┴────┬────┬────┬────┬────┬────┬────┬────┬────▶ Size
(sq.m)
50 75 100 125 150 175 200 225 250
The machine draws this line by solving a maths problem: find the line that is closest to all data
points. This line is the model — the pattern the machine has learned. With this line, it can
predict the price of any new house.
y = m × x + c
y = the thing we want to predict (house price in ₹ Lakhs)
x = the input we know (house size in sq. metres)
m = slope (how much price increases per extra sq. metre)
c = intercept (base price even for a 0 sq.m house — the starting point)
The machine found m = 0.52 and c = −0.9 by minimising a quantity called the loss — the total
error between its predictions and the actual prices. We will explore exactly how this works
Page 12
Machine Learning — A Complete Guide | Chapter 0
mathematically in Chapter 2 (Linear Regression). For now, just appreciate the big picture: the
machine learned a rule (the equation) from data, without anyone telling it the rule.
Page 13
Machine Learning — A Complete Guide | Chapter 0
⚠️ Important Caveat
Our model is only as good as our data. If we only had house sizes as input, our model
ignores important factors — location, number of bedrooms, age of building, parking
space. A better model would include all these features. This is why data quality and
feature selection are critical in ML.
Page 14
Machine Learning — A Complete Guide | Chapter 0
┌─────────────────────────────────────────────────────────────────
┐
│ FEATURE EXTRACTION — converting email to numbers
│
│
│
│ Subject contains 'FREE': 1 (yes) or 0 (no)
│
│ Subject contains 'WIN': 1 or 0
│
│ Sender in your contacts: 1 or 0
│
│ Number of exclamation marks: 7
│
│ All-caps words count: 12
│
│ Contains suspicious URL: 1 or 0
│
└─────────────────────────────────────────────────────────────────
┘
│
▼ (these numbers are fed into the ML model)
┌─────────────────────────────────────────────────────────────────
┐
│ ML MODEL
│
│ (trained on millions of known spam/not-spam emails)
│
└─────────────────────────────────────────────────────────────────
┘
Page 15
Machine Learning — A Complete Guide | Chapter 0
│
▼
OUTPUT: SPAM (0.97 confidence) → Move to Spam folder
The model was trained on millions of emails where humans had already labelled each one
'spam' or 'not spam'. The model learned which patterns (combination of features) reliably
indicate spam — and now it applies that learning to every new email in milliseconds.
👥 The Idea
'Users who behaved similarly to you in the past tended to like the same things. So we
will recommend to you what they liked next.'
It sounds simple — and the core idea is. But Netflix has 260 million users and 15,000
titles. Doing this at scale, in real-time, for every user simultaneously, is an enormous
engineering and ML challenge.
Page 16
Machine Learning — A Complete Guide | Chapter 0
• Current GPS positions of thousands of other cars on the same roads (anonymised)
• Historical traffic patterns for this road, this day of the week, this time of day
• Weather conditions (rain slows traffic by roughly 15-20%)
• Special events (cricket match, concert) near the route
• Known roadworks, accidents reported by users
The model has been trained on billions of past journeys where the actual travel time was
recorded. It finds patterns — 'when these inputs look like this, travel time is typically about X
minutes' — and applies them to your current journey.
Capture
1 The front camera takes an infrared image of your face (works in the dark too).
Detect
2 A detection model finds the face in the image and crops it.
Embed
3 A deep neural network converts your face into a list of ~128 numbers (a 'face
embedding'). This is your unique numerical face fingerprint.
Compare
It compares these 128 numbers to the stored embedding of the enrolled face
4 (yours). If the mathematical distance between the two is below a threshold →
match → unlocked.
Decision
5 If distance < threshold: UNLOCK. Else: try again or use passcode.
Those 128 numbers capture things like: distance between eyes, nose shape, jawline
curvature, cheekbone position — but NOT in a way humans explicitly programmed. The
deep network learned on its own which facial measurements best distinguish one
person from another, by training on millions of labelled face photos.
Page 17
Machine Learning — A Complete Guide | Chapter 0
Page 18
Machine Learning — A Complete Guide | Chapter 0
🐍 Why Python?
Page 19
Machine Learning — A Complete Guide | Chapter 0
new_house_size ← 175
predicted_price ← [Link](new_house_size)
Python — house_price_predictor.py
# ═══════════════════════════════════════════════════════════════
# House Price Predictor — Our First Machine Learning Program
# ═══════════════════════════════════════════════════════════════
Page 20
Machine Learning — A Complete Guide | Chapter 0
Page 21
Machine Learning — A Complete Guide | Chapter 0
📊 What is R² (R-Squared)?
R² (pronounced 'R-squared') is a number between 0 and 1 that tells you how well your
model explains the data:
• R² = 1.0 → Perfect. Your model explains 100% of the variation. (Suspicious — usually
means overfitting!)
• R² = 0.85 → Good. Model explains 85% of the variation in the target.
• R² = 0.50 → Weak. Model explains half the variation. Improve your features.
• R² = 0.0 → Useless. No better than guessing the average every time.
• R² < 0 → Worse than useless. Your model is doing something badly wrong.
Page 22
Machine Learning — A Complete Guide | Chapter 0
Page 23
Machine Learning — A Complete Guide | Chapter 0
0.1 Intelligence
• Intelligence = ability to learn from experience, reason, and adapt to new situations.
• Computers are faster but lack common sense; humans generalise better but are
slower and error-prone.
Page 24
Machine Learning — A Complete Guide | Chapter 0
Self-Test Questions
Answer these without looking back. If you struggle, re-read that section.
# Question Hint
1 In your own words: what is the difference between AI = broad. ML = learns from
AI and Machine Learning? Give one example of data.
each.
2 Why do we say Deep Learning is a subset of ML, Think of the onion diagram.
which is itself a subset of AI?
3 A chatbot is programmed with 5,000 hand-written Check the definition of ML
rules for responding to questions. Is this AI? Is it carefully.
ML?
4 In y = mx + c, what does the slope m represent in How price changes per sq. metre.
the house price example?
5 What does an R² score of 0.72 tell you about a It explains 72% of... what?
model?
6 Name 3 things about you that Netflix's Think about what you do on the
recommendation ML model likely tracks. app.
7 Why is the reshape(-1, 1) needed in the Python ML libraries expect data in a
code for the sizes array? certain shape.
── End of Chapter 0 ──
Page 25