Regression vs Classification in Machine Learning: Differences and Examples
On this page
Short answer: Both are supervised learning tasks. Regression predicts a continuous number (house price, sales next month, delivery time). Classification predicts a category (spam or not, churn yes/no, product type). Ask “Is the answer a quantity or a label?” Quantities are regression; labels are classification. They use different metrics: MAE and RMSE for regression; accuracy, precision, recall, F1 and ROC-AUC for classification.
Key takeaways
- Regression → numbers; classification → classes.
- Many algorithms (decision trees, random forests, gradient boosting) have both versions.
- Logistic regression is a classification algorithm, despite its name.
- Choosing the wrong metric is a common beginner mistake.
Regression vs classification at a glance
| Regression | Classification | |
|---|---|---|
| Output | Continuous value | Discrete class (binary or multi-class) |
| Example question | “How much?” / “How many?” | “Which one?” / “Yes or no?” |
| Examples | Price, demand, temperature, time | Spam, fraud, churn, sentiment, disease |
| Common algorithms | Linear regression, Ridge/Lasso, random forest regressor, XGBoost regressor | Logistic regression, decision tree, random forest classifier, SVM, XGBoost classifier |
| Metrics | MAE, RMSE, R² | Accuracy, precision, recall, F1, ROC-AUC |
Real-world examples
| Business problem | Type |
|---|---|
| Predict next month’s sales for each store | Regression |
| Will this customer cancel their subscription? | Classification (binary) |
| Estimate a flat’s price in Borivali from size and floor | Regression |
| Route a support ticket to billing, technical or sales | Classification (multi-class) |
| Predict a loan applicant’s probability of default | Classification (probability output) |
Python example: regression
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error
reg = RandomForestRegressor(random_state=42)
reg.fit(X_train, y_train) # y = price
print('MAE:', mean_absolute_error(y_test, reg.predict(X_test)))
Python example: classification
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report
clf = LogisticRegression(max_iter=1000)
clf.fit(X_train, y_train) # y = churned (0/1)
print(classification_report(y_test, clf.predict(X_test)))
Tricky cases
- Numbers that are really categories: pin codes or product IDs are labels, not quantities
- Ratings (1–5 stars): can be treated as regression or classification (or ordinal regression) depending on the goal
- Converting regression to classification: e.g. “Will sales exceed target?” turns a number into yes/no
- Probabilities: classifiers often output probabilities; you choose a threshold to make a decision
How to evaluate each
For regression, report MAE in business units (“off by about 3 days on average”). For classification, check precision and recall, especially for imbalanced data, rather than accuracy alone. Full guide: How to evaluate a machine learning model. Watch for overfitting in both.
Frequently asked questions
Is logistic regression regression or classification?
Classification. It predicts the probability of a class, then applies a threshold.
Can one model do both?
Algorithm families like decision trees and gradient boosting have separate regressor and classifier versions.
What about clustering?
Clustering is unsupervised: there are no labels to predict. See K-means clustering explained.
Is this asked in interviews?
Yes, frequently. See machine learning interview questions.
Conclusion
Regression vs classification comes down to the output: numbers or categories. Identify the type first, then choose suitable algorithms and metrics, and you’ve made the most important decision in any supervised ML project.
Build regression and classification projects in our Machine Learning course.
Learn with Mehul Prajapati in Borivali West
At Mehul Prajapati’s institute, you get 100% practical, hands-on training by industry experts with a minimum of 5+ years of experience, plus job-oriented programmes with placement support. Weekday and weekend batches are available, with multiple 2-hour slots between 8 am and 6 pm.
Address: 12th Floor, 1214, Gold Crest Business Centre, LT Rd, Above Westside Showroom, Borivali West, Mumbai, Maharashtra 400092
Call: +91 99301 12627 / +91 96645 45072
Visit the centre or call us to choose the right course and batch and to know the current fee structure.