What is the difference between classification and regression in Supervised Learning?

Updated Feb 20, 2026

Short answer

The key difference is the target a model learns to predict. Classification predicts a discrete category, while regression predicts a continuous numerical value. Both learn from labeled examples, but they optimize for different kinds of outputs.

Deep explanation

In supervised learning, a model learns a relationship between input data (features) and a known answer (label). The main question that separates classification from regression is: What type of answer are we asking the model to produce?

Classification answers "which group?" while regression answers "how much?"

Classification: predicting categories

Classification is used when the output belongs to a fixed set of classes. The model learns boundaries that separate one category from another.

Examples of classification problems:

  • Predict whether an email is spam or not_spam.
  • Identify whether an image contains a cat, dog, or bird.
  • Predict whether a customer will churn or stay.

The output is usually a class label, but many classification models also produce probabilities.

For example:

predict_email.py
prediction = model.predict(["You won a free prize!"])
# Output:
# "spam"

A classification model might internally estimate:

TEXT
spam: 0.92
not_spam: 0.08

Then it chooses the class with the highest probability.

Regression: predicting continuous values

Regression is used when the output is a number that can vary across a range.

Examples of regression problems:

  • Predict the price of a house.
  • Estimate tomorrow's temperature.
  • Forecast monthly sales revenue.
  • Predict the delivery time for an order.

The model learns a function that maps inputs to a numeric value.

predict_price.py
estimated_price = model.predict([
3, # bedrooms
1500, # square feet
10 # age of house
])
# Output:
# 250000

The answer is not a category. It is a measurable quantity.

Visual difference

Rendering diagram…

Comparing classification and regression

AspectClassificationRegression
Prediction typeCategory or classContinuous number
Example outputapproved, rejected45200
Common algorithmsLogistic regression, decision trees, neural networksLinear regression, regression trees, neural networks
Common metricsAccuracy, precision, recall, F1 scoreMean absolute error, mean squared error, R²

How training differs

Although both use labeled data, the model measures mistakes differently.

For classification:

  • A prediction is compared against the correct class.
  • The model learns to reduce incorrect classifications.
  • The decision boundary between classes is important.

For regression:

  • A prediction is compared against the actual number.
  • The model learns to reduce the distance between predicted and true values.
  • The size of the error matters.

For example, predicting a house price as $300,000 when the actual price is $310,000 is a smaller mistake than predicting $100,000. Regression models care about this numerical gap.

The algorithm family does not always determine the task; the output you need determines whether it is classification or regression. A decision tree can perform both tasks: a classification tree predicts categories, while a regression tree predicts numbers.

A simple interview rule: if the answer is a label, think classification; if the answer is a quantity, think regression.

A common nuance: logistic regression

A frequent beginner confusion is the name logistic regression. Despite the word "regression," it is primarily a classification algorithm.

It predicts the probability of belonging to a class:

logistic_classifier.py
probability = logistic_model.predict_proba([
customer_data
])
# Example output:
# [0.15, 0.85]

The probability might represent an 85% chance that a customer will churn. The final prediction is still a category such as churn or not_churn.

Always identify the type of prediction, not just the algorithm name, when classifying a machine learning problem.

Real-world example

Imagine an online shopping company wants to use machine learning.

For fraud detection, the company has historical transactions labeled fraud or legitimate. A classification model learns patterns such as unusual locations, spending amounts, and transaction timing, then predicts the category of a new transaction.

For revenue forecasting, the company uses past sales data to predict next month's revenue amount. A regression model learns from previous trends and outputs a number.

business_models.py
fraud_result = fraud_classifier.predict(transaction)
next_month_sales = sales_regressor.predict(month_data)

The same company can use both approaches because the business questions are different: "Is this transaction fraudulent?" is classification, while "How much will we sell?" is regression.

Common mistakes

  • * **Output confusion** - Treating every prediction problem as regression or classification without checking whether the target is a category or a number.
  • * **Algorithm confusion** - Assuming an algorithm's name defines the task
  • for example, `logistic regression` is commonly used for classification.
  • * **Ignoring probabilities** - Forgetting that classification models often predict confidence scores before selecting a final class.
  • * **Wrong metrics** - Using accuracy for price prediction or mean squared error for a class prediction leads to misleading evaluation.
  • * **Overlooking data labels** - Training requires correct historical answers
  • poor labels create unreliable supervised learning models.

Follow-up questions

  • Can a machine learning model perform both classification and regression?
  • What is the difference between classification and clustering?
  • Why is linear regression not used for classification?
  • What metrics are commonly used for classification problems?
  • What metrics are commonly used for regression problems?

More Supervised Learning interview questions

View all →