Lesson 1 of 13 · What Is ML?
What Is Machine Learning?
Machine learning in plain English: see how a computer learns a rule from examples instead of being told it, and train a tiny model right in your browser.
- 5 min read
- Beginner
- Reviewed
- What machine learning is, without the jargon
- How it differs from ordinary programming
- What training, a model and a prediction are
- Where machine learning is used every day
The big idea
In ordinary programming, a person writes the rules. To convert Celsius to Fahrenheit, a programmer types the formula and the computer follows it.
But how would you write the rules for recognising a cat in a photo? Or for deciding whether an email is spam? Nobody can list every rule. There are too many, and they keep changing.
Machine learning turns the problem around. Instead of writing rules, you show the computer many examples, and it works out the rules for itself.
| Ordinary programming | Machine learning | |
|---|---|---|
| You provide | Rules and data | Data and the correct answers |
| The computer produces | Answers | The rules |
An everyday comparison
Think about how a child learns what a dog is. Nobody gives them a definition. They see many dogs, someone says "dog" each time, and after a while they can recognise a dog they have never seen before.
Machine learning works the same way:
- Collect examples. Thousands of emails, each labelled "spam" or "not spam".
- Train. The computer searches for patterns that separate the two groups.
- Predict. A new email arrives, and the computer uses those patterns to decide.
Four words you need
After training, you give the model something new and it makes a prediction.
Train your first model
Let's make this real. Here are five students: how many hours each one studied and the score they got. The program below learns the relationship from the data, then predicts a score for a student who studies 6 hours.
You do not need to understand every line yet. Notice one thing: nowhere in the code is the rule written down. The program finds it.
hours = [1, 2, 3, 4, 5]
scores = [52, 58, 65, 71, 78]
# --- Training: find the straight line that best fits the examples ---
n = len(hours)
mean_hours = sum(hours) / n
mean_score = sum(scores) / n
top = sum((h - mean_hours) * (s - mean_score) for h, s in zip(hours, scores))
bottom = sum((h - mean_hours) ** 2 for h in hours)
slope = top / bottom
start = mean_score - slope * mean_hours
print(f"Learned rule: score = {slope:.1f} x hours + {start:.1f}")
# --- Prediction: use the rule on a value the model has never seen ---
print(f"Prediction for 6 hours: {slope * 6 + start:.1f}")The model discovered that each extra hour of study adds about 6.5 marks. Now change one of the scores, for example make the last one 95, and run it again. The rule changes, because the data changed. That is learning.
Where is machine learning used?
You already use it many times a day.
- Email filters out spam.
- Maps predict how long your journey will take.
- Streaming and shopping apps recommend what to watch or buy.
- Banks flag payments that look like fraud.
- Phones unlock by recognising your face.
- Chat assistants such as ChatGPT and Claude are built on a kind of machine learning called deep learning.
What machine learning is not
Machine learning is powerful, but it is not magic.
- A model only knows what its data shows. Poor or biased data gives poor or biased predictions.
- A model predicts. It can be confidently wrong.
- A model does not understand the world as people do. It finds patterns in numbers.
A trained model is just numbers. Use the learned slope and start to predict the score of a student who studies for 8 hours.
slope = 6.5 start = 45.3 hours = 8 # Use the learned rule (score = slope x hours + start) to predict # the score for 8 hours. Output must be exactly: Predicted score: 97.3
What is the main difference between machine learning and ordinary programming?
Summary
- Machine learning means learning rules from examples instead of writing them by hand.
- A model is the result of training on data.
- A trained model makes predictions about new cases.
- The quality of the data limits the quality of the model.
Next, you will see how machine learning, deep learning and AI relate to one another.
Finished reading? Tick it off to track your progress.