A Simple Look at Classification in Supervised Learning

Let’s take a moment to talk about something that sits at the core of machine learning: classification. It’s one of those things that sound a bit technical at first, but once you get the idea, it all starts to click.

So here we are, looking at supervised learning — a category of machine learning where we train a model on input and output pairs. Now, depending on what kind of output we’re dealing with, we either go down the road of regression or classification.

If the output is continuous, like predicting the price of a house, we use regression. But if it’s something categorical, like predicting whether an email is spam or not, that’s where classification comes in.

We’ve probably all seen some version of regression before. Think of a basic house price predictor. You feed in square footage, number of rooms, location, and it gives you a number — the estimated price. Easy enough.

But now shift gears.

Let’s say we want to teach a model to tell us whether a student passes or fails an exam based on how many hours they studied. That’s not a price or a number — it’s a label. Pass or fail. That’s where classification steps in.

What Exactly Is Classification?

Classification, in plain terms, is when we try to assign categories or labels to data based on certain input features. You give the model a set of things to look at (features), and it tells you which group the input belongs to.

Take a basic example — spam detection. Your inbox does this all the time. The model checks things like the subject line, words used in the message, sender address, etc., and then decides: spam or not. Simple, right? But under the hood, the model is making a binary classification — two possible outcomes.

Now extend that idea. What if there are more than two outcomes? Say, classifying text into positive, negative, or neutral sentiment. That becomes a multi-class classification problem. The logic is the same, the structure a bit more involved.

Let’s Talk About Logistic Regression

Even though the word regression is in the name, logistic regression is often used for classification — not predicting continuous numbers.

At its core, logistic regression tries to predict probabilities. For example, what’s the chance a student will pass the test based on hours studied?

Instead of drawing a straight line like linear regression does, logistic regression uses something called a sigmoid function. This function curves gently and maps any number into a value between 0 and 1. That range makes it easy to interpret as a probability.

Here’s how it works:

  • A student studies 6 hours. The model calculates a probability — let’s say 0.80. That’s 80% likely to pass.
  • Another student studies 2 hours, and the model gives a 0.20. That’s a 20% chance of passing.

But we still need a decision — pass or fail. So we pick a threshold, usually 0.5.

  • Anything above 0.5 is labeled as “pass.”
  • Anything below 0.5 is labeled “fail.”

This is a straightforward and interpretable way to handle binary outcomes.

Real-World Classification with the Iris Dataset

Now that we’ve got the hang of classification and logistic regression, let’s look at something a little more complex — the Iris dataset.

It’s one of the classic datasets used in machine learning. It has 150 instances of flowers from three species:

  • Iris Setosa
  • Iris Versicolor
  • Iris Virginica

Each flower is described using four features:

  • Sepal length
  • Sepal width
  • Petal length
  • Petal width

The goal? Use those features to predict which species a flower belongs to. This is no longer a simple pass/fail or spam/not-spam — it’s a three-class classification problem.

Even so, we can still use logistic regression. In this case, we just need to expand it to handle more than two classes. This is typically done using something called softmax regression, which generalizes the sigmoid function for multi-class settings.

Training the Model

So how does the model learn?

We feed it labeled data — measurements of flowers, along with their correct species. The model looks for patterns. It figures out how the combination of features tends to indicate a specific flower type.

Once trained, you can give it a new flower, and it’ll look at the measurements and say something like, “Hmm, based on what I’ve seen, there’s an 85% chance this is a Versicolor.”

And that’s classification in action.

Final Thoughts

Machine learning can feel overwhelming at first, especially with all the terminology flying around. But at the heart of it, classification is just pattern recognition. You’re giving the model examples, it’s learning from them, and then trying to make good guesses on new data.

Whether it’s figuring out if a student will pass, labeling an email as spam, or identifying a flower type, classification is everywhere.

And logistic regression? It may sound technical, but it’s one of the simplest ways to get started with building smart, predictive models.