Writing
What Is Machine Learning? Explained With Everyday Examples
Machine learning teaches computers to make and improve predictions from data. Here’s how supervised and unsupervised learning work, where you already use it, and what changed with deep learning and large language models.
By Ka Lun Chan · AI / Learning
What is machine learning?
Machine learning is a way of teaching computers to make and improve predictions from a large amount of data, instead of writing every rule by hand. The program finds the patterns in past examples and uses them to make a call about something new.
I first wrote this on my old blog as two short posts. This version keeps my explanation and examples, corrects the parts I got loose, and adds what changed once deep learning and large language models arrived.
We make difficult decisions every day. Say you’re buying a car: sports car or sedan? You weigh price, how you drive, who rides with you, what people like you ended up happy with. A machine learning model does a version of that weighing, except it learns how much each factor matters from thousands or millions of past examples rather than from gut feel. In the end the computer is trying to predict something or spot a pattern. Google’s introduction to ML puts it the same way: training software, called a model, to make useful predictions.
| Type of learning | What it learns from | Everyday example |
|---|---|---|
| Supervised | Examples with the right answer attached (labels) | Predicting your arrival time from past trips that recorded how long they took |
| Unsupervised | Examples with no labels; it looks for structure | Grouping customers with similar buying habits so a shop can treat them differently |
| Reinforcement | Rewards and penalties from actions in an environment | A game-playing program that learns which moves tend to win |
| Self-supervised | Raw data where the answer is hidden inside it, such as the next or a masked word | The pretraining step behind large language models |
How does supervised learning work?
You give the model lots of examples where the right answer is already known, it learns the relationship between the inputs and the answers, and then you check it on examples it hasn’t seen. The data is split into a training set to learn from and a test set to grade with.
My analogy still holds up. Teachers use books (training data) and quizzes (test data). The books teach; the quizzes show whether the student actually learned or just memorized the pages. A good quiz score is a reasonable guess at how the student will do on material they haven’t seen yet, and that guess is the whole point.
The split matters because a model can look brilliant on data it trained on and fail on anything new. Google’s crash course describes the test set as a proxy for real-world data, and most teams also hold back a validation set to tune the model before the final test. Here’s what that looks like with scikit-learn:
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.cluster import KMeans
X, y = load_iris(return_X_y=True)
# Supervised: learn from labelled flowers, then score on flowers it hasn't seen
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
model = LogisticRegression(max_iter=1000).fit(X_train, y_train)
print("test accuracy:", model.score(X_test, y_test))
# Unsupervised: ignore the labels and let k-means group similar flowers
groups = KMeans(n_clusters=3, random_state=0).fit_predict(X)
print(groups[:10])If you want the libraries behind that example, I cover them in NumPy and SciPy and machine learning frameworks.
What does unsupervised learning actually do?
Unsupervised learning works on data without labels and looks for structure in it. The most common job is clustering: putting similar items into groups when nobody has said what the groups should be.
When I first wrote this, I said unsupervised learning has no training data, like a teacher with no books. That was loose. There is plenty of data. What’s missing is the answer key. Nobody has marked each example as “sports car buyer” or “sedan buyer”.
A better picture is handing someone a pile of customer records and asking them to sort it into a few sensible stacks. They’d notice that some people buy often and spend little, others buy rarely and spend a lot. A clustering algorithm does that numerically. The scikit-learn clustering guide describes k-means as separating samples into a chosen number of groups so items in each group sit close together. You pick how many groups; the algorithm decides who goes where. A person still has to look at the groups and decide whether they mean anything.
Why did machine learning become so practical?
Machine learning has been around for decades. What changed is that storing data and buying computing power got cheap enough for ordinary companies to train useful models on the data they already had.
The other reason is speed. When there’s too much data and not enough answers, valuable data goes to waste because connecting it to a decision takes people too long. A model can wade through and sort that data far faster than a person, and it can be retrained as new data comes in. I called machine learning the future in the original post. It’s now simply part of how we work, drive and shop.
Where do you already use machine learning?
Shopping recommendations, map routes and arrival times, and automated customer service are three places most people use it daily without thinking about it.
- Amazon recommendations. Amazon Science describes its long-running approach, item-to-item collaborative filtering: item B is related to item A if people who buy A are unusually likely to buy B. That’s learning from purchase data at scale. Amazon has since tested neural models alongside it.
- Google Maps routes. I originally said Maps predicts the shortest route; the goal is usually the fastest. Google explains that Maps combines historical traffic patterns with live conditions to predict what traffic will be like when you reach each road, and DeepMind’s write-up covers the graph neural networks that treat the road network as connected segments to improve arrival estimates.
- Automated customer service. Natural language processing and machine learning let a system interpret what a customer typed and turn it into something the business can act on, around the clock. Today that’s mostly built on large language models, which are far more fluent and also confidently wrong more often than people expect, so a clear handoff to a human still matters.
What has changed since I first wrote this?
Deep learning took over, the transformer architecture made very large language models possible, and generative AI arrived alongside the predictive models I described. Underneath, it’s still machine learning: models trained on data and judged on data they haven’t seen.
Deep learning uses neural networks with many layers, which learn their own features from raw data such as images, audio and text. The big shift for language came from the transformer, introduced in the paper Attention Is All You Need, which trains faster in parallel than the older sequence models.
Large language models are trained in stages. First comes self-supervised pretraining on huge amounts of text: the model hides words from itself and learns to predict them, so the data supplies its own labels (Google’s LLM module describes masked prediction). Then it’s fine-tuned. The InstructGPT paper shows the common recipe: supervised fine-tuning on human-written examples, then reinforcement learning from human rankings.
That gives two broad families. Predictive ML answers a narrow question, such as what this trip will take or whether this transaction is fraud. Generative AI produces new content, such as text, code or images. For anything that needs a dependable number, the predictive kind is usually simpler to test and cheaper to run.
What are the limits of machine learning?
A model is only as good as its data and the way you check it. Biased or messy data produces biased or wrong predictions, models can memorize instead of learn, and without careful evaluation you won’t know which is happening.
- Bias. Models learn whatever is in the data, including human bias. Google’s fairness module walks through how it shows up in training data.
- Data quality. Missing, stale or mislabelled data quietly drags predictions down, and fixing it is often most of the work.
- Overfitting. A model that matches its training set too closely fails on new data. The teacher analogy again: the student memorized the book and can’t handle a new question.
- Evaluation. Accuracy on a test set is a start, not proof that the system does the job in production.
That last point is where most of the engineering effort goes once language models are involved. I wrote about it in evaluation engineering, and about the wider work in what it takes to make an AI system reliable.
Sources
Checked in November against Google’s Machine Learning Crash Course and introduction to ML, the scikit-learn documentation, Amazon Science, Google’s Maps blog, Google DeepMind’s traffic prediction post, and the transformer and InstructGPT papers. The examples, the analogies and the table are mine.
- Google for Developers: What is machine learning?
- Google Machine Learning Crash Course: Overfitting
- Google Machine Learning Crash Course: Fairness
- Google Machine Learning Crash Course: What’s a large language model?
- scikit-learn: Clustering
- Amazon Science: The history of Amazon’s recommendation algorithm
- Google: Google Maps 101, how AI helps predict traffic and determine routes
- Google DeepMind: Traffic prediction with advanced graph neural networks
- Vaswani et al.: Attention Is All You Need
- Ouyang et al.: Training language models to follow instructions with human feedback
Short answers
What is machine learning in simple terms?
It’s a way of teaching computers to make and improve predictions from a large amount of data instead of hand-written rules. The model learns patterns from past examples and uses them to make a call about something new, such as a route’s arrival time or a product you might want.
What is the difference between supervised and unsupervised learning?
Supervised learning trains on examples that already have the right answer attached, then is checked on a held-back test set. Unsupervised learning works on data with no labels and looks for structure, most often by clustering similar items into groups.
Are large language models machine learning?
Yes. They are deep learning models built on the transformer architecture, pretrained with self-supervision on large amounts of text by predicting hidden words, then fine-tuned with human-written examples and human feedback.
What are the main limits of machine learning?
Models learn whatever is in their data, including bias and errors. They can overfit by memorizing the training set and failing on new data, and a good test score doesn’t prove the system does its job in production, so evaluation matters.
Start with a prediction you can check
If you’re thinking about machine learning for your product, write down the one prediction it should make and how you’ll know it got it right before choosing a model. That test set is the most useful thing you’ll build.