Classification vs Regression
The two types of supervised learning — predicting categories vs predicting numbers
Free tier: read the explanation here. Upgrade to Pro for Drills, Speed challenges & Mastery badges.
UpgradeKnowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
Both are supervised learning, but they predict different output types:
Regression — predict a continuous numerical value - "How much will this house sell for?" → $347,500 - "What will tomorrow's temperature be?" → 22.4°C - "How many units will we sell?" → 1,847 - Metrics: MAE, MSE, RMSE, R²
Classification — predict a category (class) - "Is this email spam or not?" → Spam / Not Spam - "What digit is in this image?" → 0, 1, 2… 9 - "Will this customer churn?" → Yes / No - Metrics: Accuracy, Precision, Recall, F1, ROC-AUC
Binary vs Multiclass:
- Binary: 2 classes (spam/not spam, yes/no)
- Multiclass: 3+ classes (digit recognition: 0-9)
from sklearn.linear_model import LinearRegression, LogisticRegression
# Regression — predicts a number
reg = LinearRegression()
# Classification — predicts a class (despite its name, LogisticRegression is a classifier)
clf = LogisticRegression()Examples
Classification vs regression outputs
Classifiers have predict_proba() for class probabilities
from sklearn.linear_model import LinearRegression, LogisticRegression
import numpy as np
X = np.array([[1],[2],[3],[4],[5]])
# Regression — continuous output
y_reg = [1.2, 2.1, 2.9, 4.0, 5.1]
reg = LinearRegression().fit(X, y_reg)
print(reg.predict([[3.5]])) # [3.45] — a number
# Classification — categorical output
y_clf = [0, 0, 1, 1, 1] # 0=no, 1=yes
clf = LogisticRegression().fit(X, y_clf)
print(clf.predict([[3.5]])) # [1] — a class
print(clf.predict_proba([[3.5]])) # [[0.3, 0.7]] — probabilityHow well did you understand this?
Next in Machine Learning Basics
Features & Labels