What makes classification a different problem
What it is
The target is a label from a finite set, so the output space has no ordering or distance. Being wrong is not 'off by an amount' — it is wrong, and different kinds of wrong can cost wildly different amounts.
Why it matters
It changes the loss, the metric and the output. A regression model reports a number; a good classifier reports a probability per class, and the decision — which class to act on — is a separate step taken afterwards, with the costs in hand.
In the real world: Predicting “will this customer churn: yes or no” needs different tools and metrics than predicting how much they'll spend.
Visual example
Regression vs classificationSame pipeline shape, three differences that matter: output, loss, and what 'wrong' costs.
Why this matters
It sets up the whole module: the model's job ends at a probability, and everything about thresholds, precision and recall is the decision layer built on top.
Common misconception
Wrong idea: a classifier outputs a class.
Correct idea: it outputs a score, and predict applies a default cutoff to it. Treating the class as the model's output hides the one knob you most want.
from sklearn.linear_model import LinearRegression, LogisticRegression
import numpy as np
# Regressing on 0/1 labels: predictions escape the [0, 1] range.
LinearRegression().fit(X_train, y_train).predict(X_val[:5]) # e.g. 1.34, -0.21
clf = LogisticRegression(max_iter=1000).fit(X_train, y_train)
np.round(clf.predict_proba(X_val[:5])[:, 1], 3) # always in [0, 1]Fitting a linear regression to 0/1 labels and thresholding it. It produces impossible 'probabilities' outside [0, 1], and because squared error penalises confidently-correct points, one distant row can tilt the boundary away from a perfectly good split.