Data Science ยท Chapter 24 of 43

Regression vs Classification

REGRESSION predicts a NUMBER (price, temperature). CLASSIFICATION predicts a CATEGORY (spam / not spam).

Different metrics apply: MAE/RMSE for regression, accuracy/precision/recall for classification.

Example 1 (python)
# Regression: predict house price
from sklearn.linear_model import LinearRegression

Regression example.

Example 2 (python)
# Classification: predict spam vs not
from sklearn.linear_model import LogisticRegression

Classification example.

Key points

  • Regression โ†’ number.
  • Classification โ†’ category.
  • Different metrics per task.
  • Some algorithms handle both.
๐Ÿ’ก Note: Ordinal targets (like 1โ€“5 star ratings) sit between the two โ€” treat with care.

๐Ÿ“ Quick Quiz

1. Predicting price is:

2. Predicting spam vs not is:

3. RMSE is a metric for: