Piero Savastano
Machine Learning - Supervised vs Unsupervised Learning

Machine Learning - Supervised vs Unsupervised Learning

May 30, 2025
5 min read
Table of Contents
index

Let’s get this distinction out of the way right now, so we can proceed calmly. In our course we’ll mostly use supervised learning, the kind of learning most used in industry. But we’ll also make a small foray into unsupervised learning, which is much more interesting from an artificial intelligence perspective, but less used in industry. And there are also middle grounds: imagine a continuum between supervised and unsupervised.

Supervised: features and target

In supervised learning my dataset looks exactly like all the datasets we’ve seen so far: we have features and we have our target. The answer - the desired output - is already in the data.

In this case we condition the model to respond to a certain input with a certain output. We want the model F to approximate it as closely as possible: given X, tell me what Y is.

When do I use this? When I already have data with the output, and I want to classify it by that specific criterion. For example, I annotate tweets: I line up all my tweets and mark them - this one’s positive, this one’s negative, positive, positive, negative - and then I build a classifier that, given the text of a tweet, tells me if it’s positive or negative. It’s supervised because I act as the supervisor: I impose the output.

Unsupervised: features only

In unsupervised learning we only have the features. We don’t force an output; instead we use statistical techniques that try to extract categories bottom-up, directly from the data.

That’s exactly the difference between a classifier and clustering. In a classifier we have both features and target. In clustering we only have features, and there are statistical clustering techniques that let me extract categories directly by observing the features. I don’t force them, I extract them from below.

If my features are tweets, I can’t impose categories, but a clustering technique might pull out the topics within the tweets, the most used words, as clusters. For example, a cluster about politics, a cluster about sports - but something else entirely could come out. What you get is absolutely not guaranteed. It’s more about exploration and study.

Unsupervised learning, and clustering in particular, is used a lot to extract customer types from data, to build personas. If I have data on my customers and I want to split them into segments, this technique is useful because I don’t know the segments in advance; I want to extract them directly from the data.

Supervised learning, on the other hand, is what we use when I want to impose a certain output because I’ve recorded it in the past - for example, whether a certain customer buys a certain product or not.

In between: reinforcement learning

There are endless middle grounds, and one very interesting one is called reinforcement learning. It’s somewhat the frontier of artificial intelligence, and it’s the technique behind AlphaZero, AlphaGo and all the great AIs built by DeepMind, the London company later bought by Google.

Here we have a broader framework than machine learning; machine learning is a piece of reinforcement learning. We’re neither giving the desired output Y nor letting the model do everything by itself. It’s as if we give it hints: cold, warm, hot, freezing. We don’t give an explicit answer or say what the output should be, we give clues. The clue is usually a number, a scalar, 1 or -1, which roughly corresponds to the stick and the carrot when you train an animal to do something. It has roots in cognitive and experimental psychology, and today it also has a strong mathematical formalization.

We won’t cover reinforcement learning in this course, both because it’s quite a bit more complicated and because it isn’t used that much in industry. You’ll find it in training AIs for video games, or agents that trade on the stock market. It’s used mainly for agents that choose actions over time, where those actions affect the environment, so the environment changes the decisions the agent will make next. We can’t tell the agent the exact answer we want for a given input; we can only tell it whether it’s getting closer to the goal.

What we’ll cover

What we care about is: supervised, features and target; unsupervised, features only.

For supervised learning we’ll look at the most famous algorithms: linear regression, logistic regression, decision trees, the naive Bayes classifier and k-nearest neighbors. For unsupervised learning we’ll look at PCA, a dimensionality reduction technique, and clustering with k-means.

Within supervised learning we distinguish between classifiers and regressors. For classifiers, Y is a category. For regressors, Y is a numeric variable. In unsupervised learning there’s no such distinction, because there’s no target at all.

A small note on neural networks: they can be adapted to both contexts and everything in between. Neural networks really do anything, if you start playing with architectures. We’ll touch on that at the end of the course.

For now, what matters is the split between supervised and unsupervised. From a job perspective, that’s what’s worth focusing on, especially at the beginning, then maybe slowly explore other things. In any case, supervised learning is the most widespread in industry.