Supervised Learning

Supervised Learning Types With Examples

Learn the main supervised learning types, classification and regression, with examples of each, common algorithms and how labeled data trains a model.

On this page
  1. What supervised learning means
  2. The two main types
  3. Examples across everyday tasks
  4. Common supervised learning algorithms
  5. How labeled data trains a model
  6. Supervised learning compared with other types
  7. Choosing a supervised type for your problem
  8. The short version

Supervised learning trains a model on examples that come with the correct answer, called a label. This guide covers the main supervised learning types with examples. The short version is that the type depends on the output the model must produce: a category (classification) or a number (regression).

What supervised learning means

Each training example has an input, such as an email, and a label, such as “spam” or “not spam.” The model studies many input-label pairs, learns a rule that links inputs to labels, and is judged on how well it predicts labels for examples it has not seen.

The input can be a table of numbers, a photo or a sentence. What sets the learning task is the output.

The two main types

Classification: predicting a category

Classification assigns each input to one of a set of classes. It takes a few forms:

  • Binary classification has two classes. A spam filter decides whether an email is spam or not spam.
  • Multiclass classification picks one class from three or more. The MNIST dataset has 70,000 small images of handwritten digits, with ten classes, one for each digit from 0 to 9. The classic Iris dataset has 150 flowers from three species.
  • Multi-label classification allows several labels at once. A photo might be tagged “beach,” “sunset” and “people” all together.

Regression: predicting a number

Regression predicts a value on a continuous scale rather than choosing from a fixed list. Common examples include:

  • The price of a house, given its size, location and number of bedrooms.
  • Tomorrow’s high temperature at a weather station.
  • The number of units a store will sell next month.
  • The expected delivery time for an order.

A regression model can output any value in a range, such as 245,000 or 41.7. A classifier can only output one of its classes.

A quick test helps. If the answer could be picked from a drop-down menu, the task is classification. If the answer is a quantity you could place on a number line, the task is regression.

Examples across everyday tasks

Task Input Label in the training data Type
Spam filtering An email Spam or not spam Binary classification
Sentiment analysis A product review Positive, neutral or negative Multiclass classification
Digit recognition A small image of a digit The digit, 0 to 9 Multiclass classification
House price estimation Size, location, bedrooms The sale price Regression
Sales forecasting Past sales, season, promotions Units sold next month Regression
Object detection A photo Boxes around objects, each with a class name Classification and regression together

Object detectors such as YOLO combine both tasks. They predict where an object is, which is a set of numbers (regression), and what the object is, which is a category (classification).

Common supervised learning algorithms

Different algorithms learn the input-to-label rule in different ways. A few common ones:

  • Linear regression fits a straight-line style relationship between inputs and a number. It is often the first regression method people learn.
  • Logistic regression is a classification method despite its name. It estimates how likely an input is to belong to a class.
  • Decision trees split the data with a series of questions, such as “is the size above a set value?” They work for both classification and regression.
  • Random forests and gradient-boosted trees combine many trees into one model. They are often strong on tabular data, meaning rows and columns.
  • Support vector machines and k-nearest neighbors are classic methods. k-nearest neighbors labels a new input by looking at the labels of the closest training examples.
  • Naive Bayes is a simple, fast classifier often used for text, such as spam filtering.
  • Neural networks can handle classification and regression, and they are common for images, audio and text.

No single algorithm is best on every problem. That is the practical reason to try a few models on your own data. The idea is closely tied to the no free lunch rule in machine learning.

How labeled data trains a model

Training follows a loop:

  1. The model makes a prediction for each training input.
  2. A loss function measures how far each prediction is from its label.
  3. The learning algorithm adjusts the model to reduce that error.
  4. The loop repeats until the error stops improving.

Good practice splits labeled data three ways. The training set teaches the model. The validation set helps choose settings and catch problems during development. The test set is held back and used only at the end, to estimate how the model will do on new data.

Two problems come up often:

  • Overfitting happens when a model memorizes its training labels but fails on new data. A large gap between training and validation scores is a common warning sign.
  • Misleading accuracy happens with rare classes. If 99 of 100 emails are not spam, a filter that labels every email as not spam is 99% accurate and still catches no spam. Measures such as precision and recall show how well a model finds the rare class.

Labels also take time and money to create, and mistakes in them carry into the model.

Supervised learning compared with other types

When people ask which are the three types of machine learning, supervised learning is almost always on the list, alongside unsupervised and reinforcement learning.

  • Unsupervised learning works without labels. It looks for structure, such as grouping similar examples together or finding unusual ones.
  • Reinforcement learning learns by acting and receiving rewards or penalties, rather than from fixed correct answers.
  • Semi-supervised learning uses a small set of labeled examples alongside a large set of unlabeled ones.
  • Self-supervised learning creates its own targets from the data, such as hiding a word in a sentence and predicting it.

Self-supervised learning is where the lines get blurry. Large language models are a common example, and readers often ask “Is ChatGPT supervised or unsupervised?” The answer depends on which stage of training is meant.

Choosing a supervised type for your problem

Work through these questions in order:

  • Do you have labeled examples? If not, supervised learning is not an option yet.
  • Is the output a category or a number?
  • If it is a category, how many classes are there, and can an input belong to more than one?
  • How many examples does each class have? Rare classes need extra care.
  • Do you need to explain the predictions? Simpler models such as logistic regression and decision trees are often easier to inspect.

The short version

Supervised learning types come down to the output: classes for classification (binary, multiclass or multi-label) and numbers for regression. The examples above show the pattern. The best algorithm depends on the data, so test a few and check the results on data the model has not seen.

Keep exploring

Guides from other topics

All topics →