Unsupervised versus Supervised Machine Learning

A beginner’s guide on the two types of learning

Vinicius Monteiro
Programming For Beginners
4 min readSep 24, 2021

--

Image by chenspec from Pixabay

Many solutions in Machine Learning (ML) are implemented using either Unsupervised or Supervised learning algorithms. In this article, I cover the basics of each approach—the definition and application examples.

Supervised

Supervised learning is when the program is trained on labelled data and relies on them to infer details about new information.

A classic example is a spam email filter.

For the machine learning program to know whether an incoming email is a spam or not, the algorithm must be fed/trained beforehand, with data labelled as spam or not spam (fun fact, “not spam” is also known as “ham”).

Figure 1. Spam email filter. Taken from the book Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow — Géron, Aurélien

The spam filter is a classification problem. Another type of problem, or said task, is called regression. I already explained regression in one of my previous articles.

Here’s an example of a regression algorithm. More details here.

Linear Regression algorithm from Pragramatic Programmers page.

Supervised learning can be used for automatic text summarization (ATS) as well. Before the summarizer is launched, let’s say ready to summarize an input text, it must be trained with other original texts and their summarized versions.

It’s not the only way to automatically summarize documents, but it’s one applied technique.

Figure 1 below illustrates a common flow for an ML program.

Figure 1. ML program flow. Taken from the book Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow — Géron, Aurélien

You can see it before the launch. There is the training phase. Another key point to note from Figure 1 is that the algorithm doesn’t learn anything new after launch.

Imagine that the program learns what is a spam email or not, it’s launched, but then a spam email arrives with considerably different attributes than the ones with which the algorithm was trained. The algorithm won’t be able to handle it.

To circumvent that, the flow must be cyclical. “Launch” is not the end. The algorithm can be updated by going back to the training phase. See Figure 2.

Figure 1. ML program flow with update phase. Taken from the book Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow — Géron, Aurélien

Unsupervised

Unsupervised learning (USL) is when there is no labelled data. The algorithm can infer new information by looking at similarities of elements of the data.

The goal of the unsupervised algorithm is sort of to label the data. To segregate in different groups/clusters. Or find anomalies in it.

(going on a slight tangent) My last statement is key to understand the difference between unsupervised learning and another type of machine learning algorithms — Reinforcement Learning (RL). In RL, the program also tries to learn without labelled data, which can be confusing when differentiating with USL. But the intent of RL is different. As I explain in another article, RL is about summing up rewards to achieve the end goal and not to find labels for the data. (Ok. I’m done with RL).

Imagine the spam email filter. Imagine that the data is not labelled with “spam” or “not spam”. If we feed a bunch of information (emails) to an unsupervised learning algorithm, the program could detect similarities between spam emails versus ones that are not spam. And it will be able to group these two types in buckets.

The way Google News work is an example of Unsupervised learning. Google doesn’t know beforehand the different categories, and no human manually feeds such information.

The unsupervised learning algorithm can separate the articles based on their content and other attributes without explicitly labelled data.

Here are some Unsupervised learning algorithms.

  • Clustering (K-Means)
  • Anomaly detection and novelty detection (One-class SVM, Isolation Forest)
  • Visualization and dimensionality reduction (Kernel PCA)

Check out this amazing article written by Carolina Bento on K-means.

Final Thoughts

There are also Semi-supervised systems which are a mix of both supervised and unsupervised. Google Photos are a good example of a Semi-supervised algorithm. When you upload the photos, the program can distinguish between one person or the other. But, of course, it doesn’t know who they are. That’s where the user comes in and label each photo as your mom, dad, etc.

In short, the difference lies in having labelled data or not. The unsupervised learning algorithm goal is to find labels for the data on its own, whereas, on supervised, the data is labelled beforehand.

There are many details I didn’t cover in this post. The information here is only the tip of the iceberg, and I hope to provide it clearly and concisely.

--

--