Skip to content
BIASED

Linear classifiers and surrogate losses

Block 1 of 7~2 min

Classes as numbers

A number is not yet a decision

In Regularization we controlled the size of regression weights. Now the target is a class. Encode labels as y∈{−1,+1}y\in\{-1,+1\} and use a linear score f(x)=wTx+bf(x)=w^Tx+b. Predict +1+1 when f(x)≥0f(x)\ge0 and −1-1 otherwise. We explicitly give a zero score to the positive class.

Why not regress on these numerical labels? In a newly specified one-dimensional example, negative points are −4,−2-4,-2 and positive points are 1,31,3. Least squares with an intercept gives f(x)=(10x+5)/29f(x)=(10x+5)/29. The boundary is −1/2-1/2 and every sign is correct. Add a positive point at 4040: the fit becomes

f(x)=106x−1353353.f(x)=\frac{106x-135}{3353}.

Now the boundary has moved past the positive point at 11, although x+1/2x+1/2 still separates the data. Squared error charges a correctly classified point even when its score is much greater than 11. Fitting numerical labels and choosing correct signs are different objectives. This is an exact, fictional calculation, not a benchmark result or a claim that least-squares classification always fails.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Linear scores and lossesoptional

    Trace the exact label-fit and perceptron examples; compare conditional risks and check hinge/logistic bounds. Standard-library notebook with saved outputs.

    ~20 min · easier on a computer · Read the matching topic. Python standard library only; no downloads.

    Self-check in the notebook — not part of mastery or the certificate.