What Is Machine Learning?
Machines don't learn like humans — they learn by finding patterns in mountains of data you feed them.
is a program that analyses data and learns to predict outcomes without being explicitly programmed for each case.
EXERCISE
1What Machine Learning Actually Means
Machine learning is not a robot that thinks — it is a program that gets better at predictions by studying patterns in data.
Imagine you are a doctor who has seen 10,000 patients. Over time, you start noticing patterns — certain symptoms tend to lead to certain diagnoses. You did not memorise a rulebook; you learned from experience. Machine learning works the same way, except the "doctor" is a program and the "experience" is data.
The core idea in one sentence:
A machine learning program analyses data, finds patterns, and uses those patterns to predict outcomes it has never seen before.
# A simple prediction scenario
# We have historical data: hours studied → exam score
hours = [1, 2, 3, 4, 5, 6, 7, 8]
scores = [35, 45, 55, 60, 68, 75, 82, 90]
# ML goal: given a NEW input (9 hours), predict the score
# The program learns the RELATIONSHIP, not the individual numbers
# Output: A predicted score based on the pattern (likely ~95)
Where ML sits in the bigger picture:
| Term | What It Means |
|---|---|
| Artificial Intelligence (AI) | Machines that simulate human intelligence |
| Machine Learning (ML) | A subset of AI — learning from data |
| Deep Learning (DL) | A subset of ML — using neural networks |
Pro Tip: Machine learning is not magic — it is math applied to data. The "learning" is just the program adjusting its internal numbers until its predictions match reality as closely as possible.
EXERCISE
2How ML Programs Learn — The Prediction Loop
Every ML program follows the same loop: feed data in, find patterns, make predictions, measure errors, and improve.
Think of ML like learning to throw darts. Your first throw misses badly. But after 100 throws, you adjust based on where past darts landed. You are not memorising — you are learning the pattern of how your arm angle affects the landing spot.
The ML loop:
- Get data — collect examples with known outcomes
- Train — let the algorithm find patterns
- Predict — apply patterns to new, unseen inputs
- Evaluate — measure how wrong the predictions are
- Improve — adjust and repeat
# Step-by-step: predicting car speed from age
# Step 1: Historical data (what we KNOW)
car_ages = [5, 7, 8, 7, 2, 17, 2, 9]
car_speeds = [99, 86, 87, 88, 111, 86, 103, 87]
# Step 2: The program finds a pattern
# → Newer cars tend to be faster
# Step 3: Predict speed for a 10-year-old car
# → The model might predict ~85 km/h
# Step 4: Check if 85 is close to reality
# Step 5: Adjust if needed
# Output: prediction = ~85
Pro Tip: ML does not give you certainty — it gives you probability. A model that is right 90% of the time is extremely useful, even though it is wrong 10% of the time. The goal is never perfection; it is being useful.
EXERCISE
3When to Use Machine Learning — And When Not To
ML shines when patterns exist in data but are too complex for humans to write as rules — and it fails when data is garbage.
A calculator does not need ML — the rules are fixed. But spam detection needs ML because the rules change constantly. Spammers adapt, so the program must learn and adapt too.
Use ML when:
- The problem has patterns hidden in large data
- Writing manual rules would be impossible or constantly outdated
- You have enough quality data to learn from
Do NOT use ML when:
- A simple formula or
if/elsesolves it - You have very little data
- The outcome is purely random (no pattern exists)
# GOOD use of ML: predicting house prices
# Hundreds of features interact in complex ways
features = ["sqft", "bedrooms", "location", "age", "garage"]
# A human cannot write one formula for all cities
# ML finds the pattern from thousands of past sales
# Output: predicted_price = 342000
# BAD use of ML: converting Celsius to Fahrenheit
# This is a fixed formula — no learning needed
def to_fahrenheit(celsius):
return celsius * 9/5 + 32
print(to_fahrenheit(100))
# Output: 212
Pro Tip: The number one reason ML projects fail is not bad algorithms — it is bad data. If your data is incomplete, biased, or too small, no algorithm on earth can save you. Data quality > algorithm choice, every time.
What Is Machine Learning?
Complete lesson & earn 250 PX
