Demystifying Machine Learning: Supervised vs Unsupervised

Dagang Wei
5 min readFeb 10, 2024

--

Image generated with DALL-E

This article is part of the series Demystifying Machine Learning.

Introduction

Machine learning, a cornerstone of artificial intelligence (AI), is rapidly transforming the world around us. Within machine learning, two primary approaches command our attention: supervised learning and unsupervised learning. Let’s dive in and shed light on these intriguing concepts.

Supervised Learning: Learning with a Teacher

Supervised learning is like teaching kids with labeled flashcards. Each card has a picture on one side and its corresponding label on the other (e.g., a picture of a cat with the word “cat”). By studying these flashcards, kids learn to identify patterns and build connections between images and their labels. With enough practice, they can correctly label similar but new flashcards presented to them.

The model’s objective is to uncover the relationships between the inputs and their labels. Essentially, it learns to recognize patterns that differentiate cats from dogs. After a thorough training session, the model gains enough intelligence to predict the correct labels for new, unseen images.

Key Applications of Supervised Learning

  • Classification: Distinguishing between different objects in images, such as medical imaging analysis or product categorization. Identifying spam emails based on features like specific words or suspicious addresses.
  • Regression: Find the formula between housing price and type, age, number of room, location.
  • Prediction: Forecasting sales trends, stock prices, or customer behavior.

Common ML Models of Supervised Learning

  • Linear Regression: A classic method used to predict continuous outcomes (e.g., housing prices, sales forecasts) based on a linear relationship between input variables and the target.
  • Logistic Regression: Predicts the probability of a categorical outcome (e.g., email spam or not).
  • Decision Trees: Tree-like structures that segment data, leading to classifications or predictions.
  • Support Vector Machines (SVMs): Find the optimal boundary (hyperplane) to separate data into different classes.
  • Random Forests: A collection of decision trees working together to improve prediction accuracy.
  • Neural Networks: Complex interconnected networks inspired by the brain, capable of handling complex and nonlinear relationships in data; the backbone of Deep Learning.

Pros

  • Higher accuracy: Supervised models typically outperform unsupervised models in predictive accuracy due to the guidance of labeled data.
  • Clear goals: Supervised learning works well when you know precisely what you want the model to learn or predict.

Cons

  • Labeling requirement: Acquiring and labeling large datasets can be incredibly time-consuming, costly, and may require domain expertise.
  • Bias potential: If the training data is biased, the model’s predictions will also be biased.

Unsupervised Learning: Finding Patterns without a Teacher

Unsupervised learning is like giving kids an unlabeled deck of flashcards with various colors, shapes, fruits, and animals on them. Without labels, kids are then asked to look for patterns and group similar cards without explicit guidance. They might separate them by color, shape, type of image (fruit vs. animal), or any other patterns they recognize.

The mission of the unsupervised model is to identify hidden patterns and structures within the data. It might detect that the images tend to cluster into two groups based on features like fur length, ear shape, and other distinctive traits. While it might not directly label the groups “cats” and “dogs”, it has successfully discerned underlying patterns within the data.

Key Applications of Unsupervised Learning

  • Clustering: Grouping customers based on their purchasing habits or preferences for targeted marketing.
  • Dimensionality reduction: Simplifying complex datasets by identifying the most important features, helping with visualization and analysis.
  • Anomaly detection: Identifying unusual patterns in data, potentially pinpointing fraudulent transactions or network intrusions.

Common ML Models of Unsupervised Learning

  • K-means Clustering: Groups data into “k” clusters based on similarity.
  • Principal Component Analysis (PCA): Reduces the number of features in a dataset by identifying the most important combinations of features that explain the variance in the data.
  • Association Rule Learning: Detects frequent patterns, associations, or correlations between items or events within large datasets.

Pros

  • Uncovers hidden patterns: Excels at finding previously unknown trends, clusters, or groups within data when specific outcomes aren’t predetermined.
  • No labeling needed: This frees it from the burden of expensive, human-generated labels.

Cons

  • Less accurate: Models may not have the same precision as supervised counterparts.
  • Output interpretation: Interpreting the resulting patterns or clusters can sometimes be less intuitive or require further analysis.

The Choice: Supervised or Unsupervised?

+-------------+-----------------------------+--------------------------------+
| Feature | Supervised Learning | Unsupervised Learning |
+-------------+-----------------------------+--------------------------------+
| Data | Labeled | Unlabeled |
| Goal | Connecting input to output | Finding patterns |
| Training | Guided learning | Self-directed exploration |
| Tasks | Classification, Regression | Clustering, Dimensionality |
| | | reduction, Anomaly detection |
| Analogy | Teaching kids with labelled | Asking kids to group flashcards|
| | flashcards | based on patterns |
+-------------+-----------------------------+--------------------------------+

The best approach for a machine learning task depends on a crucial factor: the availability of labeled data. Here’s a quick guide:

  • Labeled data is plentiful: Supervised learning is the champion.
  • Unlabeled data is easy to get: Unsupervised learning steps into the spotlight.

Beyond the Basics: Semi-Supervised and Self-Supervised Learning

Think of the classroom and library analogies, but now these learning styles add a touch of cleverness for those tricky situations:

Semi-Supervised Learning: A Little Guidance Goes a Long Way

Imagine a student with a smaller set of labeled flashcards and many unlabeled ones. Semi-supervised learning leverages those labeled flashcards to kickstart the learning process, and then uses patterns found in the unlabeled flashcards to expand its understanding. This is ideal when collecting lots of data is easy, but expert labeling is costly or time-consuming.

Self-Supervised Learning: Learning from Within

Think of this as a student creating their own flashcards while exploring the library. In self-supervised learning, the model finds patterns within the data to generate its own labels. For example, with images, it might mask out a part of a photo and learn by trying to predict the missing pieces. This allows it to learn rich representations of the data without the need for human-provided labels.

Conclusion

Supervised and unsupervised learning represent pivotal building blocks of machine learning. As research continues to enhance algorithms and computing power increases, we can only anticipate increasingly sophisticated AI systems shaping our world. From revolutionizing medical diagnosis to driving personalized customer experiences, the potential of machine learning is boundless.

--

--