Linear classifiers and surrogate losses
Labels ±1, the hyperplane and the distance to it, the margin, why the error rate gives no useful gradient, convex surrogate losses and what each estimates, the perceptron as SGD, linear separability.
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 and use a linear score . Predict when and 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 and positive points are . Least squares with an intercept gives . The boundary is and every sign is correct. Add a positive point at : the fit becomes
Now the boundary has moved past the positive point at , although still separates the data. Squared error charges a correctly classified point even when its score is much greater than . 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.
The hyperplane and the distance to it
The score has a scale
For , the boundary is a hyperplane normal to . Its signed distance from a point and that point's perpendicular projection are
For , and , the score is and the projection is . Substitution into the boundary equation gives zero.
Multiplying both and by the same positive number multiplies scores but preserves all predictions and signed distances. A negative multiplier reverses the nonzero predictions. Changing only the bias moves the boundary. If , the score is constant and the distance formulas do not apply. A large score alone is therefore not an invariant confidence measure.
The margin and the error count
Add the label to the score
The functional margin is . Positive margins lie on the label's side; negative margins are mistakes. Dividing by gives a geometric margin when .
At our tie rule matters: a positive label is predicted correctly and a negative label incorrectly. The conservative count
counts both as errors. It upper-bounds actual classification error and agrees with it away from the boundary. Squared label error also has a margin form: since , .
A small change to a boundary usually leaves all signs unchanged. The empirical error is flat between crossings and jumps at a crossing, so ordinary gradient descent receives no useful direction. This is not an impossibility claim: in one dimension we can test thresholds between sorted points, and a finite strictly separable problem can be expressed by feasible linear inequalities.
Surrogate losses
Give the optimizer a direction
Replace the discontinuous error indicator with a surrogate loss. Four convex choices are
Each is nonnegative and at least for , so its average bounds the conservative error count. The division by is needed for this particular unit upper bound: natural-log logistic loss is only at zero. Scaling the data loss alone also changes its tradeoff with a fixed regularizer.
Hinge and logistic grow linearly for very negative margins; exponential grows exponentially and squared hinge quadratically. Hinge stops charging once ; logistic keeps decreasing towards zero. None is immune to outliers, because a parameter gradient also contains the feature vector.
Convexity rules out nonglobal local minima. It guarantees neither a finite minimizer nor convergence for an arbitrary step schedule. Hinge has a kink; use a subgradient there. Squared hinge has a continuous first derivative, but not a continuous second derivative at .
What each surrogate estimates
What an optimal score can tell us
Fix a feature value and write . The conditional risk is . For , its pointwise minimizers include
For hinge and , the minimizer is the majority sign, or ; it does not retain the probability's magnitude. At , every score in minimizes hinge risk. Squared error and squared hinge have optimum for interior probabilities. These are unrestricted pointwise results.
A linear model may be unable to express those scores. Specify equally likely feature values with positive probabilities . They define a fictional distribution, not measured frequencies. Independent logistic scores can be . Their mean base-two loss is and decision error .
The best linear logistic score is instead constant: , , predicting probability . Its loss is and error . The constant prediction is calibrated when grouped by its own predicted probability, yet it loses the feature-dependent probabilities. Adding to the features can express the required shape.
Classification calibration of a loss concerns its pointwise preference for the majority sign. It does not eliminate a restricted model's approximation error, finite-sample estimation error or unfinished optimization. Logistic regression, next, will separate likelihood fitting from probability calibration.
The perceptron as SGD
An update after a nonpositive margin
The perceptron uses and, with step size one, updates when :
At zero it chooses the nonzero endpoint subgradient. This choice matters: the zero parameter vector has zero perceptron loss, despite having no positive margins. The loss is not a unit upper bound on the conservative error count. Cycling through points gives incremental updates; random sampling gives the stochastic interpretation.
Our optional notebook uses positive, negative, positive, negative in that order, starting from zero. Compute a score with the current parameters, multiply by the label, then decide whether to update. A complete pass without updates establishes strict separation of these training points.
For the convergence statement, append a constant feature and include the bias in the parameter vector. Suppose all augmented inputs have norm at most and a unit separator gives every example margin at least . After updates, progress towards that separator is at least , while parameter norm is at most . Thus
This bounds updates, not passes or future errors. It requires separation. On inseparable data, repeated cycling needs a stopping rule.
Separability, and what comes next
Representation and a finite solution
The deterministic negative–positive–negative pattern at is not separable by one threshold. The score separates it after adding a quadratic feature. More data does not repair a missing feature shape by itself. Conversely, enough features can fit arbitrary labels; successful training alone does not establish generalization.
On separable data, scaling a separator sends logistic and exponential losses towards zero without attaining it at finite weights. Hinge and squared hinge can attain zero with many separators. A positive quadratic penalty on all parameters,
makes these continuous convex objectives strongly convex and coercive, so the minimum exists and is unique. Penalizing only is a different convention: with a single observed class, an unpenalized logistic bias can still diverge. Standard hard-margin SVM leaves the bias out of its norm; its geometry is treated later in Support vector machines.
The optional notebook checks the new label-fit, conditional-risk and perceptron examples with Python's standard library. It is not required for progress. These are controlled calculations, not performance or calibration evidence on real users.
Sources
Adapted with Codex assistance from the reviewed English note and Russian note, revision 82b6cb0. The small fixtures originate in that reviewed first-party renewal; the phone questions and notebook self-checks are newly composed. No third-party dataset or notebook is used.
Scientific references: Bartlett, Jordan and McAuliffe (2006), §2, Theorem 2 for classification calibration; Freund and Schapire (1999), §§2–3.1 for the perceptron update and Block–Novikoff bound. Prior conceptual references, including HSE lectures and The Elements of Statistical Learning, remain credited in the pinned source note; no reuse permission is inferred from their availability.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
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.
Answers are saved on the server and tied to this browser until you sign in.