machine learning
supervised learning
unsupervised learning
data science
artificial intelligence

What is the difference between supervised learning and unsupervised learning?

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Supervised learning and unsupervised learning are two fundamental paradigms in machine learning that address different types of problems and are applied based on the nature of the data and the problem domain. This article explores the technical differences, with examples, between these two learning paradigms.

Defining the Basics

Supervised Learning

Supervised learning is a type of machine learning where the algorithm learns from labeled training data. In this setup, each training example consists of an input object (usually a vector), and a desired output value or label:

  • Objective: The goal is to learn a mapping from inputs to outputs based on the example input-output pairs.
  • Training Data: Consists of pairs: (xi,yi)(x_i, y_i), where xix_i is the input vector, and yiy_i is the label, which indicates the output.

The major tasks within supervised learning include:

  • Regression: Predicting a continuous-valued output. Example: Predicting house prices based on features like size, location, etc.
  • Classification: Assigning an input to one of several discrete categories. Example: Classifying emails as spam or not spam.

Unsupervised Learning

Unsupervised learning involves training an algorithm using data that does not contain labels. Here, the system tries to learn the patterns and the structure from the input data:

  • Objective: The aim is to infer the natural structure present in a set of data points.
  • Training Data: Comprises only input data xix_i, and no output or target labels.

The primary tasks within unsupervised learning include:

  • Clustering: Grouping a set of objects in such a way that objects in the same group (or cluster) are more similar than those in other groups. Example: Customer segmentation in marketing.
  • Dimensionality Reduction: Reducing the number of random variables or features under consideration. Example: Principal Component Analysis (PCA).

Technical Explanations and Examples

  1. Supervised Learning Example:
    Let's take a dataset containing features of houses and their associated prices. Using supervised learning, an algorithm can be trained to predict the price of a house based on its features like size, number of rooms, and location. Techniques such as linear regression, decision trees, and neural networks can be employed for this purpose.
  2. Unsupervised Learning Example: Consider a dataset of customer purchase histories. Without any predefined labels, an algorithm like K-means can cluster these customers into different segments based on their purchasing patterns. These patterns might reveal groups like budget shoppers, luxury product buyers, etc., which were not explicitly labeled.

Comparison Table

Feature/AspectSupervised LearningUnsupervised Learning
Data LabelsRequires labeled data (x,y)(x, y) pairsNo labels required, only input data xix_i
ObjectivePredict outcomes for new, unseen dataDiscover hidden patterns or structure
TasksClassification, RegressionClustering, Dimensionality Reduction
ScenariosWhere outcomes are knownWhere relationships or patterns are unknown
ComplexityCan be computationally expensiveGenerally less computationally intense

Subtopics and Advanced Concepts

Semi-Supervised Learning

  • A mix between supervised and unsupervised learning where the model is trained on a small amount of labeled data and a large amount of unlabeled data. This approach can reduce the cost of labeling.

Reinforcement Learning

  • While distinct from both supervised and unsupervised learning, reinforcement learning involves learning through interactions with an environment to maximize cumulative rewards. It doesn't require labeled outputs but evaluates actions based on the received feedback.

Choosing Between Supervised and Unsupervised Learning

The choice between supervised and unsupervised learning depends heavily on the problem domain, the availability of labeled data, and the specific objectives of the task. When labeled data is abundant and the desired outcome is prediction or classification, supervised learning is preferred. Conversely, when exploring data to find inherent groupings or structures, unsupervised learning fits the bill.

Conclusion

Both supervised and unsupervised learning bring valuable perspectives and approaches in machine learning. Understanding their differences and appropriate application scenarios is crucial to solving diverse real-world problems efficiently. Each paradigm offers distinct methodologies and tools tailored to specific data scenarios and objectives.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.