Candidates

Companies

>

Supervised learning

Supervised learning

Supervised learning is the most common type of machine learning. It works by training a model on labeled data, a dataset where every input is paired with the correct output. The model's job is to learn the relationship between inputs and outputs so it can make accurate predictions on new data it hasn't seen before.

Think of it like studying with an answer key. You see the questions and the correct answers together, over and over, until you learn the patterns well enough to answer new questions on your own. The "supervision" in supervised learning comes from those labels. They act as a teacher, telling the model whether it got it right.

How does supervised learning work?

Supervised learning follows a straightforward process: you give the model training data, it learns patterns, and then it makes predictions.

The training data is a collection of labeled examples. Each example has input features (the information the model looks at) and a label (the correct output). A spam filter, for instance, trains on thousands of emails where each one has already been tagged as "spam" or "not spam." The model analyzes those examples and learns which features correlate with which label.

During training, the model makes predictions on the labeled examples and compares its predictions to the actual labels. When it gets something wrong, it adjusts its internal parameters to reduce the error. This process repeats across the entire training dataset, usually multiple times, until the model's predictions are reliably accurate.

Once trained, the model is tested on data it hasn't seen before to verify that it can generalize. A model that performs well on training data but fails on new data is overfitting, one of the most common problems in supervised learning.

Classification vs. regression

Supervised learning breaks down into two main task types, depending on what kind of output the model predicts.

Classification predicts a category. The output is a discrete label: spam or not spam, cat or dog, malignant or benign. The model learns to draw boundaries between categories based on the input features. Common algorithms include logistic regression, decision trees, random forests, and support vector machines. Classification is used for spam detection, image recognition, medical diagnosis, sentiment analysis, and fraud detection.

Regression predicts a continuous value. Instead of assigning a label, the model outputs a number: a house price, a temperature forecast, a stock price. The model learns the mathematical relationship between input features and the output value. Linear regression is the simplest example, but more complex methods like gradient boosting and neural networks handle non-linear relationships. Regression is used for price prediction, demand forecasting, risk scoring, and any task where the output is a number on a spectrum.

The distinction matters because it determines which algorithms you use, which metrics you evaluate, and how you structure your training data.

Common supervised learning algorithms

Different algorithms approach the pattern-learning process in different ways. The right choice depends on the task, the data, and the tradeoff between simplicity and accuracy.

Linear and logistic regression are the simplest supervised learning methods. Linear regression fits a straight line through data points to predict continuous values. Logistic regression predicts probabilities for classification tasks. Both are fast, interpretable, and work well when the relationship between features and output is relatively straightforward.

Decision trees split data into branches based on feature values, creating a tree-like structure of decisions. They're intuitive and easy to visualize, but prone to overfitting on complex datasets.

Random forests address this by building many decision trees on random subsets of the data and averaging their predictions. This reduces overfitting and improves accuracy. Random forests are among the most widely used algorithms in practice.

Support vector machines (SVMs) find the optimal boundary between classes by maximizing the margin between data points. They work well for high-dimensional data and smaller datasets.

Neural networks are the foundation of deep learning. They process data through layers of interconnected nodes, learning increasingly complex patterns at each layer. They're the most powerful supervised learning tool for large datasets and complex tasks, but require more data and compute than simpler methods.

Supervised vs. unsupervised learning

This is the most fundamental comparison in machine learning.

Supervised learning needs labeled data. Every training example includes the correct answer, and the model learns to map inputs to outputs. It's used for prediction.

Unsupervised learning works with unlabeled data. The model has no correct answers to train on. Instead, it discovers structure in the data on its own. It's used for when you don't know what you're looking for yet.

The practical difference often comes down to data availability. Labeled data is expensive and time-consuming to create. Someone has to look at every example and assign the correct label. Unsupervised learning sidesteps this by working with raw data, which is why it scales better for tasks where labeling isn't feasible.

In real-world machine learning pipelines, the two frequently work together. Unsupervised learning might cluster customer data into segments, and then supervised learning predicts which segment a new customer belongs to. Modern LLMs use self-supervised learning (a form of unsupervised learning) for pre-training and supervised techniques for post-training.

What is self-supervised learning?

Self-supervised learning bridges the gap between supervised and unsupervised learning. It trains on unlabeled data (like unsupervised learning) but generates its own labels from the data itself (making it function like supervised learning).

Here's how it works: instead of relying on humans to label every example, the model creates its own training task from the raw data. For language models, the most common approach is next-token prediction. The model sees a sequence of text with the last word hidden and learns to predict what comes next. The hidden word is the "label," but it was generated automatically from the data, not by a human annotator.

This is the training method behind every major LLM. GPT, Claude, and Gemini are all pre-trained using self-supervised learning on massive text datasets. The model sees trillions of tokens and learns to predict the next one, which is how it develops its understanding of language, grammar, reasoning patterns, and factual knowledge.

Self-supervised learning matters because it solves the biggest bottleneck in supervised learning: the need for labeled data. Manually labeling billions of text examples would be impossible. Self-supervised learning lets models train on the enormous amounts of unlabeled text that already exist on the internet, making it scalable in a way that traditional supervised learning never could be.

For vision models, self-supervised learning works differently. The model might learn by predicting missing patches of an image, identifying which images are rotated, or distinguishing between augmented versions of the same image. The principle is the same: create a training signal from the data itself.

Is reinforcement learning supervised or unsupervised?

Neither. Reinforcement learning is a third paradigm with its own distinct approach.

In supervised learning, the model learns from labeled examples. In unsupervised learning, the model finds patterns in unlabeled data. Reinforcement learning does neither. Instead, a model (called an agent) learns by taking actions in an environment and receiving rewards or penalties based on the outcomes.

There's no dataset to train on in the traditional sense. The agent generates its own experience through trial and error. A chess-playing agent doesn't study labeled game positions. It plays games, wins or loses, and adjusts its strategy based on the results.

Reinforcement learning is used for game playing, robotics, autonomous vehicles, and for aligning language models with human preferences through RLHF (reinforcement learning from human feedback). In RLHF, human preference rankings serve as the reward signal that shapes model behavior during post-training.

Is deep learning supervised or unsupervised?

Deep learning isn't a learning paradigm; it's an architecture. It refers to neural networks with many layers, and it can be used with any learning type.

Supervised deep learning is what powers image classification (convolutional neural networks trained on labeled images), speech recognition (models trained on paired audio and transcriptions), and most traditional NLP tasks (models trained on labeled text data).

Unsupervised deep learning includes autoencoders (which learn compressed representations of data) and generative adversarial networks (GANs), which learn to generate realistic data without labels.

Self-supervised deep learning is how LLMs are pre-trained. Deep neural networks trained on unlabeled text using next-token prediction.

Deep reinforcement learning combines deep neural networks with reinforcement learning, which is how AlphaGo learned to play Go and how modern robotics systems learn complex physical tasks.

When people say "deep learning" without qualification, they're usually referring to supervised deep learning, since that's where the technology had its earliest breakthroughs. But the architecture is flexible across all paradigms.

Real-world examples of supervised learning

Supervised learning is everywhere, often working behind the scenes in products you use daily.

Email spam filtering. Gmail and other email services train classifiers on millions of labeled emails to automatically sort spam from legitimate messages. The model learns which combinations of sender, subject, and content features indicate spam.

Medical diagnosis. AI systems trained on labeled medical images assist doctors in detecting conditions like cancer, diabetic retinopathy, and pneumonia. The model learns to identify visual patterns associated with each diagnosis.

Voice assistants. Siri, Alexa, and Google Assistant use supervised learning for speech recognition, converting audio into text by training on huge datasets of paired speech recordings and transcriptions.

Credit scoring. Banks train models on historical loan data to predict the likelihood that a new applicant will default.

Autonomous vehicles. Self-driving systems use supervised learning to train object detection models, learning to identify pedestrians, vehicles, traffic signs, and lane markings from labeled camera and sensor data.

FAQs

What is supervised learning?

Supervised learning is a type of machine learning where a model trains on labeled data to learn patterns and make predictions on new data. It's the most common and widely used form of machine learning.

What's the difference between supervised and unsupervised learning?

Supervised learning uses labeled data to predict specific outputs. Unsupervised learning uses unlabeled data to discover patterns and structure. Supervised learning requires someone to define the correct answers; unsupervised learning finds answers on its own.

What is self-supervised learning?

Self-supervised learning trains on unlabeled data but generates its own labels from the data itself. For LLMs, this means predicting the next word in a sequence; the hidden word is the auto-generated label. It's how every major language model (GPT, Claude, Gemini) is pre-trained.

Is reinforcement learning supervised or unsupervised?

Neither. Reinforcement learning is a third paradigm where a model learns through trial and error, receiving rewards or penalties for its actions. It doesn't use labeled datasets or explore unlabeled data for patterns.

Is deep learning supervised or unsupervised?

Deep learning is an architecture (neural networks with many layers), not a learning paradigm. It can be used for supervised, unsupervised, self-supervised, or reinforcement learning tasks depending on the application.

What are the two main types of supervised learning tasks?

Classification (predicting a category, like spam vs. not spam) and regression (predicting a continuous value, like a house price). The type of task determines which algorithms and evaluation metrics to use.