Skip to content
beginner

Regression vs Classification: Identify the Prediction Problem First

You have data. You have a prediction goal. And you're stuck on a question that feels like it should be simple: should I use regression or classification?

Published 2026-09-08Updated 2026-09-1211 min read
Close-up of a car dashboard at night with illuminated speedometer and tech displays.
Close-up of a car dashboard at night with illuminated speedometer and tech displays. Photo by Doci on Pexels.

You have data. You have a prediction goal. And you're stuck on a question that feels like it should be simple: should I use regression or classification?

Here's the trap most beginners fall into: they treat this as an algorithm choice, as if the answer comes from memorizing which model names belong to which bucket. It doesn't work that way. The real question is about your target—the thing you're trying to predict. Once you can name what kind of answer your target demands, the regression vs classification decision makes itself.

The Question That Decides Everything: What Is Your Target?

A flowchart starts with the target to predict and branches to a continuous number, leading to regression with examples such as price and temperature, or a fixed category, leading to classification with examples such as spam versus not spam and cat versus dog. The classification branch also shows that class probabilities can support the final label.
Start with the kind of answer you need: a continuous number points to regression, while a fixed category points to classification.

In supervised learning, you train a model to predict a target from features. The features are your inputs—the information you have. The target is the answer you want the model to produce. If you need a refresher on how features and targets work, that's the foundation everything else builds on. For now, the key idea is simple: supervised learning always has a target, and the type of that target determines your task.

So here's the deciding question: What kind of answer does your target demand?

Not "which model should I use?" Not "what's the most popular algorithm?" Just: what shape does the correct answer take?

There are two possible shapes:

  • A continuous number that can fall anywhere within a range. Think price, temperature, or time.
  • A discrete category from a fixed set. Think "spam" or "not spam," "cat" or "dog."

That's the entire boundary. Continuous target means regression. Categorical target means classification.

Here's what makes this concrete: the same dataset can support either task, depending on what you're trying to predict. Imagine you have data about houses: square footage, number of bedrooms, location, age of the property. If your target is price, you're solving a regression problem—you want a number that could be $250,000 or $487,500 or anything in between. If your target is whether the house will sell within 30 days, you're solving a classification problem—the answer is "yes" or "no."

Same features. Same data. Different target, different task.

Note: The rule is about the answer you need at prediction time, not just how the data happens to be stored. If you predict a patient's exact hospital stay in days, that's regression. If you predict whether the stay will exceed 30 days, that's classification—even though both start from the same length-of-stay information. Turning a number into a category changes the question and discards detail. Choose the task that matches the decision you actually need to make.

Knowledge check

Check your understanding

Answer this question before you continue.

A hospital wants to predict the exact number of days each patient will stay. Which task type matches this target?
Scenario Interpretation

Focus: Identify regression or classification from the kind of target answer required.

Regression: Predicting a Number

Regression is the machine learning task of predicting a continuous numerical value. In plain terms: the model outputs a number that can fall anywhere along a range.

Real-world regression problems are everywhere:

  • Predicting a house's sale price from its size, location, and condition
  • Forecasting tomorrow's temperature from weather data
  • Estimating a building's energy usage in kilowatt-hours from its characteristics
  • Predicting how many days a patient will stay in the hospital

What makes these regression problems is that the target is a number with meaningful granularity. A house isn't just "expensive" or "cheap"—it's worth $312,000, and the difference between $311,000 and $312,000 matters.

How does a regression model learn? It discovers a mapping from features to a numeric value. During training, the model makes predictions, compares them to the true numbers in your data, and adjusts itself to get closer. The core mechanism is simple: the model is penalized by how far off its predictions are.

That penalty is called a loss, and for regression it's usually based on distance. The most common intuition is squared error: if the true price is $300,000 and the model predicts $280,000, the error is $20,000, and the model feels that miss more strongly than a $5,000 miss. Squaring the error means big mistakes hurt disproportionately, which pushes the model to avoid them.

You don't need the math yet. Just hold onto this: regression models are judged by how close their numbers come to the real numbers.

Knowledge check

Check your understanding

Answer this question before you continue.

What does a regression loss primarily measure according to the article?
Single Choice

Focus: Explain how regression training and evaluation relate prediction errors to the true numerical values.

Classification: Predicting a Category

Classification is the machine learning task of assigning an observation to one of a fixed set of categories. The model outputs a label, not a number.

Classification problems are just as common:

  • Determining whether an email is spam or not spam
  • Identifying whether an image contains a cat or a dog
  • Predicting whether it will rain tomorrow
  • Diagnosing which stage of a disease a patient has

When there are only two possible categories, it's called binary classification. Spam or not spam. Rain or no rain. The two-class case is the simplest and most common starting point.

When there are more than two categories, it's called multiclass classification. An image classifier that can output "cat," "dog," or "bird" is solving a multiclass problem. So is a model that predicts whether tomorrow will bring rain, hail, snow, or sleet.

Here's where beginners often get confused. Many classifiers don't directly output a label. Instead, they output a probability for each class—say, 0.85 for "spam" and 0.15 for "not spam." The predicted label is whichever class has the highest probability, but the probabilities themselves are a separate, valuable output. They tell you not just what the model thinks, but how strongly it thinks so.

That distinction matters more than it seems. The highest-probability class is not always the best decision. Imagine a medical screening model that predicts a 40% chance of disease and a 60% chance of no disease. If the cost of missing a real case is far higher than the cost of a false alarm, you might send the patient for further testing even though "no disease" has the higher probability. The label comes from the probabilities, but the decision can depend on what each kind of mistake costs you.

This is also the perfect moment to clear up one of the most persistent naming traps in machine learning: logistic regression is not a regression model. Despite the name, it's a classification algorithm. It predicts the probability that something belongs to a category, then assigns the label based on that probability. The "regression" in the name is a historical artifact, not a description of what it does.

Knowledge check

Check your understanding

Answer this question before you continue.

A screening model gives disease a probability of 40% and no disease a probability of 60%. Why might a clinician still send the patient for further testing?
Comparison Reasoning

Focus: Distinguish class probabilities, predicted labels, and decisions based on the costs of mistakes.

Regression vs Classification: Side by Side

Here's a compact comparison to keep as a reference. Don't memorize it—use it.

RegressionClassification
Output typeContinuous numberDiscrete category, often with a probability for each class
What the model learnsA mapping from features to a numeric valueA boundary that separates categories
Training objectiveMinimize distance between predicted and true numbersPenalize low probability assigned to the true class
What you evaluateHow close predictions are to real valuesHow often labels are right, and which mistakes matter
Typical evaluation metricsMean squared error, mean absolute errorAccuracy, precision, recall

The evaluation difference is worth understanding, because it changes how you judge whether your model is any good.

For regression, you ask: how close are the predictions? Mean squared error and mean absolute error both measure the average distance between predicted values and true values. A model with lower error is better.

For classification, you ask: how often is the label right, and which mistakes does the model make? Accuracy gives you the overall rate of correct predictions. But accuracy can hide problems when one category is rare or when mistakes have very different costs.

Consider spam filtering. A false positive sends a legitimate email to the spam folder—a real email your customer never sees. A false negative lets one spam message through—annoying, but not damaging. Those two mistakes are not interchangeable, and a model that optimizes only for overall accuracy won't distinguish between them. Precision and recall measure exactly that distinction: precision asks whether the things you flagged as spam were actually spam, while recall asks whether you caught the spam that actually arrived. Which one matters more depends on the cost of each mistake in your specific situation.

Common Mistakes Beginners Make

Let me save you the debugging time. These are the mistakes I see beginners make most often when they're first choosing between regression and classification.

Mistake 1: Using a regression model on a categorical target, or a classifier on a continuous target. This mismatch produces meaningless results. A regression model asked to predict "spam or not spam" will output numbers like 0.7, which don't map cleanly to either category. A classifier asked to predict house price will try to force a continuous range into discrete buckets and lose all the granularity that makes the prediction useful.

Instead: Check your target type first. Continuous number? Regression. Category? Classification.

Mistake 2: Assuming logistic regression is a regression technique. The name is a trap. Logistic regression predicts probabilities and assigns class labels. It belongs firmly on the classification side.

Instead: When you see "logistic regression," translate it in your head to "logistic classifier."

Mistake 3: Confusing an ordered category with a continuous number. Just because categories have an order doesn't make them numeric. "Low risk, medium risk, high risk" looks like it could be 1, 2, 3—but the gap between low and medium isn't the same as the gap between medium and high. These are ordinal categories, and they're still categories.

Instead: If the target can only take a fixed set of values, it's categorical. Treat it as classification.

Mistake 4: Thinking regression and classification are mutually exclusive model types. They're not. They're task types. Many model families can handle both. Decision trees, for example, can predict a continuous value or assign a category depending on how they're configured. The task comes first; the model family comes second.

Instead: Choose your task from your target, then pick a model family that can handle that task.

Knowledge check

Check your understanding

Answer this question before you continue.

A target has the fixed values “low risk,” “medium risk,” and “high risk.” Which task type does the article recommend?
Misconception Check

Focus: Recognize that ordered categories remain categorical targets rather than continuous numerical targets.

A Quick Decision Rule for Your Own Data

When you face a new dataset and a prediction goal, run this three-step checklist:

  1. Name your target column. What exactly are you trying to predict?
  2. Ask what shape the answer can take. Can it be any number within a range? Or is it limited to a fixed set of categories?
  3. Choose the task. Continuous range means regression. Fixed categories mean classification.

Let's walk through it on a fresh scenario. Suppose you run a small online store and you have historical data on every order: what was purchased, when, from which marketing channel, and at what price. You want to predict something useful for the next month.

Prediction goal one: How much revenue will next Tuesday bring? The target is revenue in dollars. It could be $412 or $1,208 or any value in between. That's a continuous number. Regression.

Prediction goal two: Will this customer make another purchase within 90 days? The target is "yes" or "no." There are exactly two possible answers. That's a category. Classification.

Same store, same data, two different tasks—because the targets demand different kinds of answers.

The choice of task always comes before the choice of algorithm. Once you know you're solving a regression problem, you can explore regression model families. Once you know you're solving a classification problem, you can explore classifiers. But you can't pick a sensible model until you know what job it needs to do.

Here's your next step: before you touch any code, practice labeling real-world prediction goals as regression or classification. Pull up a few datasets you find interesting, or just think about questions you'd like answered from data you already have. For each one, name the target, ask what shape the answer takes, and commit to a task type. It takes five minutes, and it builds the instinct you'll rely on for every modeling project after this.

The pattern is simple: name the target, check its shape, let the answer pick the task. Get that right, and you'll never stare blankly at a dataset wondering which kind of model you need again.

Knowledge check

Final check

Finish the article by checking the ideas you just learned.

An online store wants to predict whether a customer will make another purchase within 90 days. What should the store choose?
Question 1 of 2Scenario Interpretation

Focus: Apply the target-shape decision rule to distinguish numerical and categorical prediction goals.

Which workflow follows the article’s recommended order for a new prediction problem?
Question 2 of 2Comparison Reasoning

Focus: Explain why the prediction task should be selected from the target before choosing a model family.

References

  1. What is Machine Learning?developers.google.com
  2. Classification vs Regression | IBMwww.ibm.com
  3. 1.1. Linear Models — scikit-learn 1.9.0 documentationscikit-learn.org
8sources checked
8source domains
6searches run

Research updated Sep 8, 2026

Related sites

Continue across the AI learning path

Use LearnPyFast for Python foundations and LearnLLMFast when you are ready to move from classical ML into LLM applications.

Python tutorialstutorial

LearnPyFast

Beginner-friendly Python tutorials, examples, and learning paths for practical programming foundations.

PythonProgrammingBeginners
Visit LearnPyFast
LLM tutorialstutorial

LearnLLMFast

Practical LLM tutorials for builders who want to understand prompting, workflows, agents, and AI applications.

LLMAIBuilders
Visit LearnLLMFast

Keep learning

Related machine learning tutorials

Continue with nearby concepts, model families, evaluation methods, and practical workflows.