What is Machine Learning? Supervised, Unsupervised, and Reinforcement Learning Explained
Machine learning is a branch of artificial intelligence where systems learn from data to make predictions without being explicitly programmed. Learn the three main paradigms — supervised, unsupervised, and reinforcement learning — with practical examples and real-world applications.
On this page
- How machine learning differs from classical programming
- The three main paradigms
- Supervised learning
- Unsupervised learning
- Reinforcement learning
- How to get started
- The relationship between AI and machine learning
- FAQ
- What is the difference between supervised and unsupervised learning?
- Can reinforcement learning be used without a simulation of the environment?
- How is deep learning different from classical machine learning?
- What are the main limitations of machine learning?
- Summary
In traditional programming, a developer writes explicit rules that a computer follows to produce an output. If you want a program to detect spam, you write rules such as "flag emails that contain the word 'winner' and come from an unknown sender." Machine learning takes a different approach: instead of writing the rules, you give the computer examples of inputs and their correct outputs, and it learns the rules from the data.
Machine learning (ML) is a field of study within artificial intelligence concerned with the development and study of statistical algorithms that can learn from data and generalize to unseen data, and thus perform tasks without being explicitly programmed. The term was coined in 1959 by Arthur Samuel, an IBM employee and pioneer in computer gaming and AI, who built one of the earliest ML programs — a checkers-playing system that improved its play through self-practice.
The field draws deeply from statistics and mathematical optimisation. The core insight is simple: instead of hand-coding a solution, you let the algorithm discover patterns. Advances in deep learning — a class of algorithms called neural networks — have pushed ML past many previous benchmarks in image recognition, natural language processing, and game playing.
How machine learning differs from classical programming
The difference comes down to where the rules live:
- Classical programming: you write the rules; the computer applies them to data and produces output.
- Machine learning: you give the computer examples of input-output pairs (the training data); the algorithm learns the rules that map inputs to outputs.
This flip is what makes ML powerful for problems where writing explicit rules is impractical — face recognition, language translation, fraud detection, and recommendation systems all have rules too complex or too implicit to hand-code.
The three main paradigms
Most machine learning problems fall into one of three categories.
Supervised learning
In supervised learning, the training data consists of labeled examples — each input comes paired with the correct output. The algorithm learns to map inputs to outputs by comparing its predictions to the known correct answers and adjusting accordingly.
Wikipedia describes supervised learning as learning from example input-output pairs, where the "supervisor" is the labeled training data. It covers two main problem types:
- Classification — predicting a category: spam or not spam, a digit from 0 to 9, whether a tumor is benign or malignant.
- Regression — predicting a continuous value: the price of a house, tomorrow's temperature, a user's expected lifetime value.
Practical examples include email spam filters (trained on thousands of emails labeled as spam or not spam), medical diagnosis systems (trained on patient records with known outcomes), and credit scoring models (trained on past loan applicants with known repayment histories).
from sklearn.ensemble import RandomForestClassifier
# Supervised learning: classification
# Each row has features (email words, length, links) and a label (spam / not spam)
X_train = [[1, 0, 3], [0, 1, 1], [1, 1, 0]] # example feature vectors
y_train = ["spam", "not_spam", "spam"]
model = RandomForestClassifier()
model.fit(X_train, y_train)
prediction = model.predict([[1, 0, 2]]) # → ["spam"]
Unsupervised learning
In unsupervised learning, the data has no labels. The algorithm's job is to find structure — groups, patterns, or anomalies — without being told what to look for. Wikipedia defines it as finding hidden patterns in unlabeled data.
Common techniques include:
- Clustering — grouping similar items together. Customer segmentation groups shoppers by purchasing behavior so a business can tailor marketing to each group.
- Dimensionality reduction — simplifying high-dimensional data (say, 1,000 features from an image) into fewer dimensions while preserving key structure, used to speed up ML pipelines or visualise data.
- Anomaly detection — flagging unusual patterns, such as fraudulent transactions that differ from a customer's normal behavior.
Unsupervised learning is harder to evaluate because there is no ground truth to compare against, but it is invaluable when labels are expensive or impossible to obtain.
from sklearn.cluster import KMeans
# Unsupervised learning: clustering
# The algorithm discovers 3 groups without any labels provided
X = [[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]]
model = KMeans(n_clusters=3, random_state=42)
labels = model.fit_predict(X)
# → [0, 0, 0, 1, 1, 1] (two natural clusters found)
Reinforcement learning
Reinforcement learning (RL) is the third major paradigm. As Wikipedia describes it, RL involves an agent that takes actions in an environment to maximise a cumulative reward signal. Unlike supervised learning — where the correct answer is provided for each input — the agent only receives a reward signal (positive or negative) that tells it how well it did, but not what the right action was.
RL solves sequential decision problems where actions have long-term consequences. The agent must balance exploration (trying new actions to discover better strategies) with exploitation (using the best-known strategy). This is called the exploration-exploitation dilemma.
RL has powered landmark achievements: AlphaGo defeated a professional human Go player in 2016 using deep neural networks combined with tree search. RL also drives robotic control systems, autonomous vehicle navigation, and adaptive recommendation engines.
How to get started
You can start with practical tools that require little background:
- Python with scikit-learn or TensorFlow — the most common ML stack. scikit-learn covers classical algorithms (decision trees, random forests, clustering, regression) in a clean, beginner-friendly API. TensorFlow and its Keras interface are the standard for deep learning.
- Google Colab — a free browser-based Jupyter notebook environment with GPUs provided at no cost. You can run scikit-learn, TensorFlow, or PyTorch code immediately without installing anything.
- No-code tools — platforms such as Google AutoML, Azure Machine Learning, and DataRobot let you upload data and train models through a GUI, abstracting away the code entirely.
A typical beginner workflow: load a dataset, split it into training and test sets, train a model on the training set, evaluate its accuracy on the held-out test set, and iterate on model choice or feature engineering until performance is acceptable.
The relationship between AI and machine learning
It helps to keep the scope clear. Artificial intelligence is the broad goal of building machines that can perform tasks that would otherwise require human intelligence. Machine learning is one of the primary approaches to achieving that goal — specifically, systems that learn from data rather than following hard-coded rules.
Other AI approaches include rule-based expert systems, symbolic reasoning, and search algorithms. ML has become the dominant approach because of its empirical strength: on problems with abundant data, ML systems consistently outperform systems built on hand-crafted rules.
FAQ
What is the difference between supervised and unsupervised learning?
Supervised learning uses labeled data — every training example has a known correct answer — and the algorithm minimises the gap between its predictions and those known answers. Unsupervised learning works on unlabeled data and finds structure without any reference answers. If you have labels, supervised methods almost always produce better predictions; if you do not have labels, unsupervised methods are the only option.
Can reinforcement learning be used without a simulation of the environment?
In many cases, yes. You can train RL agents directly in the real world (called online or live RL), though this is slower and riskier — a wrong action might cause physical damage. A common middle ground is model-based RL, where the agent first builds a model of the environment from collected experience, then simulates further training within that model before acting in the real world. Pure model-free RL (such as Q-learning) typically needs many environment interactions, which makes it impractical for expensive real-world settings.
How is deep learning different from classical machine learning?
Classical ML algorithms — decision trees, random forests, logistic regression, support vector machines — require careful feature engineering: the practitioner decides which aspects of the input to extract and feed to the model. Deep learning uses neural networks with many layers that automatically learn hierarchical feature representations from raw data (pixels, audio waveforms, text). For problems with rich, unstructured inputs — images, audio, natural language — deep learning dramatically outperforms classical ML. For structured tabular data, classical ML often matches or exceeds deep learning with less complexity.
What are the main limitations of machine learning?
ML systems fail when data is scarce, biased, or unrepresentative of the real world. A model trained only on data from one region or demographic will perform poorly for others. ML can also be a black box — even the model's creators may not be able to explain why a specific prediction was made. This raises concerns in high-stakes domains such as healthcare, criminal justice, and finance. Other challenges include overfitting (a model that memorises the training data but fails on new examples), data privacy, and the computational cost of training large models.
Summary
Machine learning flips the classical programming model: instead of writing explicit rules, you give the algorithm data and let it discover the rules. The three main paradigms serve different problems. Supervised learning maps labeled inputs to outputs — the right choice when you have examples of the right answer. Unsupervised learning finds hidden structure in unlabeled data — useful for exploration, clustering, and anomaly detection. Reinforcement learning trains agents through reward signals in an environment — the approach behind game-playing systems and robotics. Together they power everything from your email spam filter to large language models.
Sources
- Wikipedia — Machine learning (en.wikipedia.org/wiki/Machine_learning
- CC BY-SA 4.0)
- Wikipedia — Supervised learning (en.wikipedia.org/wiki/Supervised_learning
- CC BY-SA 4.0)
- Wikipedia — Reinforcement learning (en.wikipedia.org/wiki/Reinforcement_learning
- CC BY-SA 4.0)
- Wikipedia — Artificial intelligence (en.wikipedia.org/wiki/Artificial_intelligence
- CC BY-SA 4.0)
Share this guide
Related guides
- What is an API? A plain-language guide to how APIs work
What an API is, how REST APIs work over HTTP, the methods you'll actually meet — GET, POST, PUT, PATCH, DELETE — and how to read a response.
- Docker explained: how containers work
Docker explained: what containers are, how Docker Engine uses Linux namespaces and cgroups, how images, Dockerfiles, and Docker Compose fit together, and how Docker compares with virtual machines.
- Git explained: how version control works
Git explained: what version control is, how Git stores history as content-addressed snapshots, why branches are cheap, and how Git and GitHub fit together.