Logistic Regression
Logistic regression models a binary label as a Bernoulli variable. Its probability is a sigmoid of a linear function of the input :
Here are the weights and is the bias. The sigmoid maps any real number into . Inverting it shows that the model is linear in the log-odds:
The left side is the logit of , and is the odds. Raising by one unit multiplies the odds by . Predicting when is the same as predicting it when . The decision boundary is therefore a hyperplane, as for any linear discriminant.The parameters are fit by maximum likelihood. With , label has Bernoulli probability . The negative log-likelihood of independent samples is the binary cross-entropy loss:
Each sample contributes when and when . Absorb into by adding a column of ones to the design matrix , whose rows are the samples. Let and be the vectors of the and the . The gradient and the Hessian are
The Hessian is positive semidefinite, so is convex and every stationary point is a global minimum. Setting the gradient to zero gives nonlinear equations with no closed-form solution. Two solvers are standard:
- Gradient methods: gradient descent or SGD take steps with learning rate .
- Newton’s method: each step sets and then recomputes and (6.2. Newton’s Method). For this loss it is called iteratively reweighted least squares (IRLS).
The minimizer is unique and finite when has full column rank and the two classes overlap. Overlap here means that no hyperplane separates the classes, even with some points lying on it. On separable data has no finite minimizer, and the weights grow without bound. An penalty fixes this. The penalized fit minimizes with , usually leaving unpenalized, and adds to the gradient. When both classes appear in the data, the penalized loss is strictly convex and has a unique finite minimizer. This fit is the MAP estimate under a Gaussian prior on . 3.8.3 Bayesian Logistic Regression treats the full posterior.
Intuition
Linear regression on labels predicts numbers outside , and points far from the boundary pull its fit. Logistic regression keeps the linear score and passes it through the sigmoid, which turns any score into a probability. Large positive scores give probabilities near , and large negative scores give probabilities near . A score of gives . The name comes from the logistic function . The model counts as a “regression” because it fits the log-odds as a linear function of .
The fit asks which weights make the observed labels most probable. A confident mistake costs a lot. Predicting for a positive example costs , while costs . The gradient has the same form as the least-squares gradient, with the residual in place of . Each example changes the weights in proportion to the error in its probability.
Properties
(Separable Data Diverges) On separable data the loss approaches zero only as the weights grow without bound.
Suppose puts every positive example on the positive side and every negative example on the negative side. Scaling both by keeps the boundary and pushes each toward its label, so as . Every finite has , so no minimizer exists. Gradient descent then never converges to a finite point. Soudry et al. (2018) showed that grows like after steps. The direction converges to the hard-margin SVM direction, with the bias treated as one more weight. The fitted probabilities approach and , so the model overstates its confidence. In quasi-complete separation, a few points sit exactly on the boundary. That case also has no finite maximum likelihood estimate (Albert and Anderson 1984). An penalty or early stopping keeps the weights finite.
The animation scales up on separable data. Every predicted probability moves closer to its label. The negative log-likelihood keeps falling and never reaches zero.
\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\newcommand{\ra}[2]{\draw[thick] (#1) -- (#2); \filldraw[draw=black, fill=hot] (#1) circle (2.6pt);}
\newcommand{\bh}[1]{\draw[cold, thick, fill=white] (#1) circle (2.4pt);}
\newcommand{\bv}[1]{\filldraw[draw=black, fill=cold] (#1) circle (2.6pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}, xshift=4.3cm]
\begin{scope}[]
\filldraw[draw=black, fill=mid] (4.90,-2.3) rectangle (5.50,0.10);\node[above] at (5.20,0.10) {\footnotesize $5.448$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 14.6s = "true", repeats}}}]
\filldraw[draw=black, fill=mid] (5.75,-2.3) rectangle (6.35,-1.02);\node[above] at (6.05,-1.02) {\footnotesize $2.908$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 14.6s = "true", repeats}}}]
\filldraw[draw=black, fill=mid] (6.60,-2.3) rectangle (7.20,-1.82);\node[above] at (6.90,-1.82) {\footnotesize $1.091$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.3s = "true", 14.6s = "true", repeats}}}]
\filldraw[draw=black, fill=mid] (7.45,-2.3) rectangle (8.05,-2.20);\node[above] at (7.75,-2.20) {\footnotesize $0.227$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.4s = "true", 14.6s = "true", repeats}}}]
\draw[mid, thick] (-1.36,-0.77) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.15,0.79);
\fill[white] (2.42,2.48) -- (2.62,2.81) -- (2.01,2.87) -- cycle;
\fill[white] (0.76,-0.92) -- (0.87,-0.78) -- (-1.23,1.25) -- (-1.33,1.11) -- cycle;
\fill[white] (0.44,-0.95) -- (0.76,-0.92) -- (-1.33,1.11) -- (-1.57,1.07) -- (-1.60,1.02) -- cycle;
\fill[white] (2.21,2.15) -- (2.42,2.48) -- (2.01,2.87) -- (1.40,2.93) -- cycle;
\fill[white] (0.87,-0.78) -- (0.96,-0.46) -- (-1.14,1.56) -- (-1.23,1.25) -- cycle;
\fill[white] (-0.17,-0.89) -- (0.44,-0.95) -- (-1.60,1.02) -- (-1.81,0.69) -- cycle;
\fill[white] (2.01,1.82) -- (2.21,2.15) -- (1.40,2.93) -- (0.78,3.00) -- cycle;
\fill[white] (0.96,-0.46) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.14,1.56) -- cycle;
\fill[white] (-0.78,-0.83) -- (-0.17,-0.89) -- (-1.81,0.69) -- (-2.01,0.35) -- cycle;
\fill[white] (1.81,1.48) -- (2.01,1.82) -- (0.78,3.00) -- (0.17,3.06) -- cycle;
\fill[white] (1.05,0.07) -- (1.14,0.61) -- (-0.96,2.63) -- (-1.05,2.10) -- cycle;
\fill[white] (-1.40,-0.76) -- (-0.78,-0.83) -- (-2.01,0.35) -- (-2.21,0.02) -- cycle;
\fill[white] (1.60,1.15) -- (1.81,1.48) -- (0.17,3.06) -- (-0.44,3.12) -- cycle;
\fill[white] (1.14,0.61) -- (1.23,0.92) -- (-0.87,2.95) -- (-0.96,2.63) -- cycle;
\fill[white] (-2.01,-0.70) -- (-1.40,-0.76) -- (-2.21,0.02) -- (-2.42,-0.31) -- cycle;
\fill[white] (1.33,1.06) -- (1.57,1.10) -- (1.60,1.15) -- (-0.44,3.12) -- (-0.76,3.09) -- cycle;
\fill[white] (1.23,0.92) -- (1.33,1.06) -- (-0.76,3.09) -- (-0.87,2.95) -- cycle;
\fill[white] (-2.62,-0.64) -- (-2.01,-0.70) -- (-2.42,-0.31) -- cycle;
\draw[mid] (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid] (-2.01,-0.70) -- (-2.41,-0.31);
\draw[mid] (-1.40,-0.76) -- (-2.21,0.02);
\draw[mid] (-0.78,-0.83) -- (-2.01,0.35);
\draw[mid] (-0.17,-0.89) -- (-1.80,0.68);
\draw[mid] (0.44,-0.95) -- (-1.60,1.02);
\draw[mid] (0.76,-0.92) -- (-1.33,1.10);
\draw[mid] (0.87,-0.78) -- (-1.23,1.25);
\draw[mid] (0.96,-0.46) -- (-1.14,1.56);
\draw[mid] (1.14,0.61) -- (-0.96,2.63);
\draw[mid] (1.23,0.92) -- (-0.87,2.95);
\draw[mid] (1.33,1.07) -- (-0.76,3.09);
\draw[mid] (1.60,1.15) -- (-0.44,3.12);
\draw[mid] (1.80,1.49) -- (0.17,3.06);
\draw[mid] (2.01,1.82) -- (0.78,3.00);
\draw[mid] (2.21,2.15) -- (1.40,2.93);
\draw[mid] (2.41,2.48) -- (2.01,2.87);
\draw[mid] (2.62,2.81) -- (2.62,2.81);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.92) -- (0.38,-0.89) -- (0.62,-0.78) -- (0.70,-0.62) -- (0.77,-0.28) -- (0.84,0.28) -- (0.91,0.83) -- (0.98,1.17) -- (1.06,1.33) -- (1.30,1.44) -- (1.77,1.52) -- (1.83,1.53);
\draw[mid] (-1.57,-0.75) -- (-1.44,-0.72) -- (-0.97,-0.64) -- (-0.51,-0.56) -- (-0.04,-0.48) -- (0.20,-0.38) -- (0.28,-0.21) -- (0.35,0.13) -- (0.42,0.68) -- (0.49,1.23) -- (0.56,1.57) -- (0.64,1.74) -- (0.88,1.84) -- (1.35,1.93) -- (1.81,2.00) -- (2.16,2.06);
\draw[mid] (-2.49,-0.43) -- (-2.32,-0.40) -- (-1.86,-0.32) -- (-1.39,-0.24) -- (-0.93,-0.16) -- (-0.46,-0.08) -- (-0.22,0.03) -- (-0.14,0.19) -- (-0.07,0.53) -- (0.00,1.09) -- (0.07,1.64) -- (0.14,1.98) -- (0.22,2.14) -- (0.46,2.25) -- (0.93,2.33) -- (1.39,2.41) -- (1.86,2.49) -- (2.32,2.57) -- (2.49,2.60);
\draw[mid] (-2.16,0.11) -- (-1.81,0.17) -- (-1.35,0.25) -- (-0.88,0.33) -- (-0.64,0.43) -- (-0.56,0.60) -- (-0.49,0.94) -- (-0.42,1.49) -- (-0.35,2.04) -- (-0.28,2.38) -- (-0.20,2.55) -- (0.04,2.65) -- (0.51,2.73) -- (0.97,2.81) -- (1.44,2.89) -- (1.57,2.92);
\draw[mid] (-1.83,0.64) -- (-1.77,0.65) -- (-1.30,0.73) -- (-1.06,0.84) -- (-0.98,1.00) -- (-0.91,1.34) -- (-0.84,1.89) -- (-0.77,2.45) -- (-0.70,2.79) -- (-0.62,2.95) -- (-0.38,3.06) -- (-0.18,3.09);
\draw[thick] (-2.62,-0.64) -- (-2.01,-0.70) -- (-1.40,-0.76) -- (-0.78,-0.83) -- (-0.17,-0.89) -- (0.44,-0.95) -- (0.76,-0.92) -- (0.87,-0.78) -- (0.96,-0.46) -- (1.05,0.07) -- (1.14,0.61) -- (1.23,0.92) -- (1.33,1.06) -- (1.57,1.10);
\draw[thick] (1.57,1.10) -- (1.60,1.15) -- (1.81,1.48) -- (2.01,1.82) -- (2.21,2.15) -- (2.42,2.48) -- (2.62,2.81) -- (2.62,2.81);
\draw[thick] (2.62,2.81) -- (2.01,2.87) -- (1.40,2.93) -- (0.78,3.00) -- (0.17,3.06) -- (-0.44,3.12) -- (-0.76,3.09) -- (-0.87,2.95) -- (-0.96,2.63) -- (-1.05,2.10) -- (-1.14,1.56) -- (-1.23,1.25) -- (-1.33,1.11) -- (-1.57,1.07);
\draw[thick] (-1.57,1.07) -- (-1.60,1.02) -- (-1.81,0.69) -- (-2.01,0.35) -- (-2.21,0.02) -- (-2.42,-0.31) -- (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid, dashed] (-2.62,-0.64) -- (-1.36,-0.77);
\draw[mid, dashed] (1.15,0.79) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.86}
\ra{1.14,2.84}{1.14,2.84}
\ra{0.66,2.73}{0.66,2.73}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.38);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.55}
\ra{0.86,2.46}{0.86,2.46}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.23);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.31}
\draw[dashed] (-0.95,-0.14) -- (-0.95,-0.14);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,-0.17);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.18);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.98}
\ra{1.55,1.88}{1.55,1.88}
\draw[dashed] (-0.06,-0.44) -- (-0.06,-0.43);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.53);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.67);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 16.00$, \ $\mathbf w = (12.80, 9.60)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 0.014$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.4s = "true", 14.6s = "true", repeats}}}]
\filldraw[draw=black, fill=mid] (8.30,-2.3) rectangle (8.90,-2.29);\node[above] at (8.60,-2.29) {\footnotesize $0.014$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 2.8s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.78,0.72);
\draw[mid, thick] (-2.54,-0.51) -- (-2.62,-0.64);
\fill[white] (2.42,2.29) -- (2.62,2.69) -- (2.01,2.68) -- cycle;
\fill[white] (2.36,2.17) -- (2.42,2.29) -- (2.01,2.68) -- (1.83,2.67) -- cycle;
\fill[white] (2.21,1.86) -- (2.36,2.17) -- (1.83,2.67) -- (1.40,2.64) -- cycle;
\fill[white] (2.01,1.39) -- (2.21,1.86) -- (1.40,2.64) -- (0.78,2.57) -- cycle;
\fill[white] (1.88,1.06) -- (2.01,1.39) -- (0.78,2.57) -- (0.39,2.49) -- cycle;
\fill[white] (1.81,0.87) -- (1.88,1.06) -- (0.39,2.49) -- (0.17,2.45) -- cycle;
\fill[white] (1.60,0.32) -- (1.81,0.87) -- (0.17,2.45) -- (-0.44,2.28) -- cycle;
\fill[white] (1.05,0.07) -- (1.57,0.23) -- (1.60,0.32) -- (-0.44,2.28) -- (-1.05,2.10) -- cycle;
\fill[white] (0.44,-0.11) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.57,1.94) -- (-1.60,1.85) -- cycle;
\fill[white] (-0.17,-0.28) -- (0.44,-0.11) -- (-1.60,1.85) -- (-1.81,1.30) -- cycle;
\fill[white] (-0.39,-0.32) -- (-0.17,-0.28) -- (-1.81,1.30) -- (-1.88,1.11) -- cycle;
\fill[white] (-0.78,-0.40) -- (-0.39,-0.32) -- (-1.88,1.11) -- (-2.01,0.78) -- cycle;
\fill[white] (-1.40,-0.47) -- (-0.78,-0.40) -- (-2.01,0.78) -- (-2.21,0.31) -- cycle;
\fill[white] (-1.83,-0.50) -- (-1.40,-0.47) -- (-2.21,0.31) -- (-2.36,0.01) -- cycle;
\fill[white] (-2.01,-0.51) -- (-1.83,-0.50) -- (-2.36,0.01) -- (-2.42,-0.12) -- cycle;
\fill[white] (-2.62,-0.52) -- (-2.01,-0.51) -- (-2.42,-0.12) -- cycle;
\draw[mid] (-2.62,-0.52) -- (-2.62,-0.52);
\draw[mid] (-2.01,-0.51) -- (-2.41,-0.12);
\draw[mid] (-1.83,-0.50) -- (-2.35,0.00);
\draw[mid] (-1.40,-0.47) -- (-2.21,0.31);
\draw[mid] (-0.78,-0.40) -- (-2.01,0.78);
\draw[mid] (-0.39,-0.32) -- (-1.88,1.11);
\draw[mid] (-0.17,-0.28) -- (-1.80,1.30);
\draw[mid] (0.44,-0.11) -- (-1.60,1.85);
\draw[mid] (1.60,0.32) -- (-0.44,2.28);
\draw[mid] (1.80,0.87) -- (0.17,2.45);
\draw[mid] (1.88,1.06) -- (0.39,2.49);
\draw[mid] (2.01,1.39) -- (0.78,2.57);
\draw[mid] (2.21,1.86) -- (1.40,2.64);
\draw[mid] (2.35,2.17) -- (1.83,2.67);
\draw[mid] (2.41,2.29) -- (2.01,2.68);
\draw[mid] (2.62,2.69) -- (2.62,2.69);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.19) -- (0.38,-0.05) -- (0.84,0.28) -- (1.30,0.60) -- (1.77,0.91) -- (1.83,0.95);
\draw[mid] (-1.57,-0.49) -- (-1.44,-0.43) -- (-0.97,-0.21) -- (-0.67,-0.05) -- (-0.51,0.05) -- (-0.04,0.35) -- (0.42,0.68) -- (0.88,1.01) -- (1.35,1.31) -- (1.51,1.41) -- (1.81,1.58) -- (2.16,1.74);
\draw[mid] (-2.49,-0.26) -- (-2.32,-0.21) -- (-2.19,-0.16) -- (-1.86,-0.03) -- (-1.39,0.19) -- (-1.09,0.36) -- (-0.93,0.45) -- (-0.46,0.76) -- (0.00,1.09) -- (0.46,1.41) -- (0.93,1.72) -- (1.09,1.82) -- (1.39,1.98) -- (1.86,2.20) -- (2.19,2.33) -- (2.32,2.38) -- (2.49,2.43);
\draw[mid] (-2.16,0.43) -- (-1.81,0.60) -- (-1.51,0.76) -- (-1.35,0.86) -- (-0.88,1.16) -- (-0.42,1.49) -- (0.04,1.82) -- (0.51,2.12) -- (0.67,2.22) -- (0.97,2.38) -- (1.44,2.60) -- (1.57,2.66);
\draw[mid] (-1.83,1.22) -- (-1.77,1.26) -- (-1.30,1.57) -- (-0.84,1.89) -- (-0.38,2.22) -- (-0.18,2.36);
\draw[thick] (-2.62,-0.52) -- (-2.01,-0.51) -- (-1.83,-0.50) -- (-1.40,-0.47) -- (-0.78,-0.40) -- (-0.39,-0.32) -- (-0.17,-0.28) -- (0.44,-0.11) -- (1.05,0.07) -- (1.57,0.23);
\draw[thick] (1.57,0.23) -- (1.60,0.32) -- (1.81,0.87) -- (1.88,1.06) -- (2.01,1.39) -- (2.21,1.86) -- (2.36,2.17) -- (2.42,2.29) -- (2.62,2.69) -- (2.62,2.69);
\draw[thick] (2.62,2.69) -- (2.01,2.68) -- (1.83,2.67) -- (1.40,2.64) -- (0.78,2.57) -- (0.39,2.49) -- (0.17,2.45) -- (-0.44,2.28) -- (-1.05,2.10) -- (-1.57,1.94);
\draw[thick] (-1.57,1.94) -- (-1.60,1.85) -- (-1.81,1.30) -- (-1.88,1.11) -- (-2.01,0.78) -- (-2.21,0.31) -- (-2.36,0.01) -- (-2.42,-0.12) -- (-2.62,-0.52) -- (-2.62,-0.52);
\draw[mid, dashed] (1.78,0.72) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.54,-0.51);
\ra{-0.37,2.87}{-0.37,1.95}
\ra{1.14,2.84}{1.14,2.46}
\ra{0.66,2.73}{0.66,2.17}
\draw[dashed] (-1.15,0.38) -- (-1.15,1.13);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.18}
\ra{0.86,2.46}{0.86,1.87}
\draw[dashed] (-0.64,0.23) -- (-0.64,1.12);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,1.96}
\draw[dashed] (-0.95,-0.14) -- (-0.95,0.48);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,0.68);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,0.15);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.16}
\ra{1.55,1.88}{1.55,1.33}
\draw (-0.06,-0.44) -- (-0.06,-0.22);
\draw[dashed] (-0.06,-0.22) -- (-0.06,0.42);
\bv{-0.06,-0.44}
\draw (-1.11,-0.53) -- (-1.11,-0.42);
\draw[dashed] (-1.11,-0.42) -- (-1.11,-0.10);
\bv{-1.11,-0.53}
\draw (-0.56,-0.67) -- (-0.56,-0.34);
\draw[dashed] (-0.56,-0.34) -- (-0.56,-0.11);
\bv{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 1.00$, \ $\mathbf w = (0.80, 0.60)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 5.448$};
\node[anchor=west] at (-4.3,-3.30) {Class $0$ sits on the floor and class $1$ at height $1$. Each stick is the gap to the surface.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 3.1s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.68,0.74);
\draw[mid, thick] (-2.59,-0.60) -- (-2.62,-0.64);
\fill[white] (2.47,2.50) -- (2.62,2.77) -- (2.17,2.79) -- cycle;
\fill[white] (2.42,2.40) -- (2.47,2.50) -- (2.17,2.79) -- (2.01,2.80) -- cycle;
\fill[white] (2.21,2.00) -- (2.42,2.40) -- (2.01,2.80) -- (1.40,2.79) -- cycle;
\fill[white] (2.08,1.71) -- (2.21,2.00) -- (1.40,2.79) -- (0.99,2.76) -- cycle;
\fill[white] (2.01,1.55) -- (2.08,1.71) -- (0.99,2.76) -- (0.78,2.73) -- cycle;
\fill[white] (1.81,1.03) -- (2.01,1.55) -- (0.78,2.73) -- (0.17,2.60) -- cycle;
\fill[white] (1.74,0.83) -- (1.81,1.03) -- (0.17,2.60) -- (-0.03,2.54) -- cycle;
\fill[white] (1.60,0.41) -- (1.74,0.83) -- (-0.03,2.54) -- (-0.44,2.38) -- cycle;
\fill[white] (1.05,0.07) -- (1.57,0.32) -- (1.60,0.41) -- (-0.44,2.38) -- (-1.05,2.10) -- cycle;
\fill[white] (0.44,-0.21) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.57,1.85) -- (-1.60,1.76) -- cycle;
\fill[white] (0.03,-0.37) -- (0.44,-0.21) -- (-1.60,1.76) -- (-1.74,1.34) -- cycle;
\fill[white] (-0.17,-0.43) -- (0.03,-0.37) -- (-1.74,1.34) -- (-1.81,1.14) -- cycle;
\fill[white] (-0.78,-0.56) -- (-0.17,-0.43) -- (-1.81,1.14) -- (-2.01,0.62) -- cycle;
\fill[white] (-0.99,-0.59) -- (-0.78,-0.56) -- (-2.01,0.62) -- (-2.08,0.46) -- cycle;
\fill[white] (-1.40,-0.62) -- (-0.99,-0.59) -- (-2.08,0.46) -- (-2.21,0.17) -- cycle;
\fill[white] (-2.01,-0.62) -- (-1.40,-0.62) -- (-2.21,0.17) -- (-2.42,-0.23) -- cycle;
\fill[white] (-2.17,-0.62) -- (-2.01,-0.62) -- (-2.42,-0.23) -- (-2.47,-0.33) -- cycle;
\fill[white] (-2.62,-0.60) -- (-2.17,-0.62) -- (-2.47,-0.33) -- cycle;
\draw[mid] (-2.62,-0.60) -- (-2.62,-0.60);
\draw[mid] (-2.17,-0.62) -- (-2.47,-0.33);
\draw[mid] (-2.01,-0.62) -- (-2.41,-0.23);
\draw[mid] (-1.40,-0.62) -- (-2.21,0.17);
\draw[mid] (-0.99,-0.59) -- (-2.07,0.46);
\draw[mid] (-0.78,-0.56) -- (-2.01,0.62);
\draw[mid] (-0.17,-0.43) -- (-1.80,1.14);
\draw[mid] (0.03,-0.37) -- (-1.74,1.34);
\draw[mid] (0.44,-0.21) -- (-1.60,1.76);
\draw[mid] (1.60,0.41) -- (-0.44,2.38);
\draw[mid] (1.74,0.83) -- (-0.03,2.54);
\draw[mid] (1.80,1.03) -- (0.17,2.60);
\draw[mid] (2.01,1.55) -- (0.78,2.73);
\draw[mid] (2.07,1.71) -- (0.99,2.76);
\draw[mid] (2.21,2.00) -- (1.40,2.79);
\draw[mid] (2.41,2.40) -- (2.01,2.80);
\draw[mid] (2.47,2.50) -- (2.17,2.79);
\draw[mid] (2.62,2.77) -- (2.62,2.77);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.31) -- (0.38,-0.15) -- (0.84,0.28) -- (1.30,0.70) -- (1.61,0.95) -- (1.77,1.06) -- (1.83,1.11);
\draw[mid] (-1.57,-0.63) -- (-1.44,-0.58) -- (-1.13,-0.45) -- (-0.97,-0.38) -- (-0.51,-0.11) -- (-0.35,0.01) -- (-0.04,0.26) -- (0.42,0.68) -- (0.88,1.11) -- (1.19,1.36) -- (1.35,1.47) -- (1.81,1.74) -- (1.97,1.81) -- (2.16,1.90);
\draw[mid] (-2.49,-0.37) -- (-2.45,-0.35) -- (-2.32,-0.32) -- (-1.86,-0.17) -- (-1.55,-0.05) -- (-1.39,0.02) -- (-0.93,0.30) -- (-0.77,0.41) -- (-0.46,0.66) -- (0.00,1.09) -- (0.46,1.51) -- (0.77,1.76) -- (0.93,1.87) -- (1.39,2.15) -- (1.55,2.22) -- (1.86,2.34) -- (2.32,2.49) -- (2.45,2.53) -- (2.49,2.54);
\draw[mid] (-2.16,0.27) -- (-1.97,0.36) -- (-1.81,0.43) -- (-1.35,0.70) -- (-1.19,0.81) -- (-0.88,1.06) -- (-0.42,1.49) -- (0.04,1.92) -- (0.35,2.17) -- (0.51,2.28) -- (0.97,2.55) -- (1.13,2.62) -- (1.44,2.75) -- (1.57,2.80);
\draw[mid] (-1.83,1.06) -- (-1.77,1.11) -- (-1.61,1.22) -- (-1.30,1.47) -- (-0.84,1.89) -- (-0.38,2.32) -- (-0.18,2.48);
\draw[thick] (-2.62,-0.60) -- (-2.17,-0.62) -- (-2.01,-0.62) -- (-1.40,-0.62) -- (-0.99,-0.59) -- (-0.78,-0.56) -- (-0.17,-0.43) -- (0.03,-0.37) -- (0.44,-0.21) -- (1.05,0.07) -- (1.57,0.32);
\draw[thick] (1.57,0.32) -- (1.60,0.41) -- (1.74,0.83) -- (1.81,1.03) -- (2.01,1.55) -- (2.08,1.71) -- (2.21,2.00) -- (2.42,2.40) -- (2.47,2.50) -- (2.62,2.77) -- (2.62,2.77);
\draw[thick] (2.62,2.77) -- (2.17,2.79) -- (2.01,2.80) -- (1.40,2.79) -- (0.99,2.76) -- (0.78,2.73) -- (0.17,2.60) -- (-0.03,2.54) -- (-0.44,2.38) -- (-1.05,2.10) -- (-1.57,1.85);
\draw[thick] (-1.57,1.85) -- (-1.60,1.76) -- (-1.74,1.34) -- (-1.81,1.14) -- (-2.01,0.62) -- (-2.08,0.46) -- (-2.21,0.17) -- (-2.42,-0.23) -- (-2.47,-0.33) -- (-2.62,-0.60) -- (-2.62,-0.60);
\draw[mid, dashed] (1.68,0.74) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.59,-0.60);
\ra{-0.37,2.87}{-0.37,2.02}
\ra{1.14,2.84}{1.14,2.62}
\ra{0.66,2.73}{0.66,2.33}
\draw[dashed] (-1.15,0.38) -- (-1.15,1.01);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.34}
\ra{0.86,2.46}{0.86,2.03}
\draw[dashed] (-0.64,0.23) -- (-0.64,1.05);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.12}
\draw[dashed] (-0.95,-0.14) -- (-0.95,0.33);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,0.58);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.00);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.26}
\ra{1.55,1.88}{1.55,1.49}
\draw (-0.06,-0.44) -- (-0.06,-0.37);
\draw[dashed] (-0.06,-0.37) -- (-0.06,0.32);
\bv{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.27);
\bh{-1.11,-0.53}
\draw (-0.56,-0.67) -- (-0.56,-0.51);
\draw[dashed] (-0.56,-0.51) -- (-0.56,-0.28);
\bv{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 1.41$, \ $\mathbf w = (1.13, 0.85)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 4.143$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 4.9s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.68,0.74);
\fill[white] (2.42,2.46) -- (2.62,2.80) -- (2.01,2.85) -- cycle;
\fill[white] (2.21,2.10) -- (2.42,2.46) -- (2.01,2.85) -- (1.40,2.88) -- cycle;
\fill[white] (2.16,1.99) -- (2.21,2.10) -- (1.40,2.88) -- (1.23,2.89) -- cycle;
\fill[white] (2.01,1.69) -- (2.16,1.99) -- (1.23,2.89) -- (0.78,2.87) -- cycle;
\fill[white] (1.88,1.38) -- (2.01,1.69) -- (0.78,2.87) -- (0.39,2.82) -- cycle;
\fill[white] (0.33,-0.40) -- (0.44,-0.34) -- (-1.60,1.63) -- (-1.64,1.50) -- cycle;
\fill[white] (0.44,-0.34) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.57,1.74) -- (-1.60,1.63) -- cycle;
\fill[white] (-0.17,-0.60) -- (0.33,-0.40) -- (-1.64,1.50) -- (-1.81,0.98) -- cycle;
\fill[white] (1.81,1.19) -- (1.88,1.38) -- (0.39,2.82) -- (0.17,2.77) -- cycle;
\fill[white] (-0.39,-0.65) -- (-0.17,-0.60) -- (-1.81,0.98) -- (-1.88,0.79) -- cycle;
\fill[white] (1.64,0.67) -- (1.81,1.19) -- (0.17,2.77) -- (-0.33,2.57) -- cycle;
\fill[white] (1.05,0.07) -- (1.57,0.43) -- (1.60,0.54) -- (-0.44,2.51) -- (-1.05,2.10) -- cycle;
\fill[white] (1.60,0.54) -- (1.64,0.67) -- (-0.33,2.57) -- (-0.44,2.51) -- cycle;
\fill[white] (-0.78,-0.70) -- (-0.39,-0.65) -- (-1.88,0.79) -- (-2.01,0.48) -- cycle;
\fill[white] (-1.23,-0.72) -- (-0.78,-0.70) -- (-2.01,0.48) -- (-2.16,0.18) -- cycle;
\fill[white] (-1.40,-0.71) -- (-1.23,-0.72) -- (-2.16,0.18) -- (-2.21,0.07) -- cycle;
\fill[white] (-2.01,-0.68) -- (-1.40,-0.71) -- (-2.21,0.07) -- (-2.42,-0.29) -- cycle;
\fill[white] (-2.62,-0.63) -- (-2.01,-0.68) -- (-2.42,-0.29) -- cycle;
\draw[mid] (-2.62,-0.63) -- (-2.62,-0.63);
\draw[mid] (-2.01,-0.68) -- (-2.41,-0.29);
\draw[mid] (-1.40,-0.71) -- (-2.21,0.07);
\draw[mid] (-1.23,-0.72) -- (-2.16,0.18);
\draw[mid] (-0.78,-0.70) -- (-2.01,0.48);
\draw[mid] (-0.39,-0.65) -- (-1.88,0.78);
\draw[mid] (-0.17,-0.60) -- (-1.80,0.98);
\draw[mid] (0.33,-0.40) -- (-1.64,1.50);
\draw[mid] (0.44,-0.34) -- (-1.60,1.63);
\draw[mid] (1.60,0.54) -- (-0.44,2.51);
\draw[mid] (1.64,0.67) -- (-0.33,2.57);
\draw[mid] (1.80,1.20) -- (0.17,2.77);
\draw[mid] (1.88,1.39) -- (0.39,2.82);
\draw[mid] (2.01,1.69) -- (0.78,2.87);
\draw[mid] (2.16,1.99) -- (1.23,2.89);
\draw[mid] (2.21,2.10) -- (1.40,2.88);
\draw[mid] (2.41,2.46) -- (2.01,2.85);
\draw[mid] (2.62,2.80) -- (2.62,2.80);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.47) -- (0.29,-0.36) -- (0.38,-0.28) -- (0.84,0.28) -- (1.30,0.83) -- (1.39,0.91) -- (1.77,1.23) -- (1.83,1.27);
\draw[mid] (-1.57,-0.71) -- (-1.44,-0.67) -- (-1.31,-0.64) -- (-0.97,-0.52) -- (-0.67,-0.38) -- (-0.51,-0.27) -- (-0.13,0.04) -- (-0.04,0.13) -- (0.42,0.68) -- (0.88,1.23) -- (0.97,1.32) -- (1.35,1.63) -- (1.51,1.74) -- (1.81,1.88) -- (2.15,2.00) -- (2.16,2.00);
\draw[mid] (-2.49,-0.41) -- (-2.32,-0.38) -- (-1.86,-0.27) -- (-1.73,-0.23) -- (-1.39,-0.11) -- (-1.09,0.03) -- (-0.93,0.13) -- (-0.55,0.45) -- (-0.46,0.53) -- (0.00,1.09) -- (0.46,1.64) -- (0.55,1.72) -- (0.93,2.04) -- (1.09,2.14) -- (1.39,2.29) -- (1.73,2.40) -- (1.86,2.44) -- (2.32,2.55) -- (2.49,2.58);
\draw[mid] (-2.16,0.17) -- (-2.15,0.17) -- (-1.81,0.29) -- (-1.51,0.43) -- (-1.35,0.54) -- (-0.97,0.85) -- (-0.88,0.94) -- (-0.42,1.49) -- (0.04,2.04) -- (0.13,2.13) -- (0.51,2.44) -- (0.67,2.55) -- (0.97,2.69) -- (1.31,2.81) -- (1.44,2.84) -- (1.57,2.88);
\draw[mid] (-1.83,0.90) -- (-1.77,0.94) -- (-1.39,1.26) -- (-1.30,1.34) -- (-0.84,1.89) -- (-0.38,2.45) -- (-0.29,2.53) -- (-0.18,2.64);
\draw[thick] (-2.62,-0.63) -- (-2.01,-0.68) -- (-1.40,-0.71) -- (-1.23,-0.72) -- (-0.78,-0.70) -- (-0.39,-0.65) -- (-0.17,-0.60) -- (0.33,-0.40) -- (0.44,-0.34) -- (1.05,0.07) -- (1.57,0.43);
\draw[thick] (1.57,0.43) -- (1.60,0.54) -- (1.64,0.67) -- (1.81,1.19) -- (1.88,1.38) -- (2.01,1.69) -- (2.16,1.99) -- (2.21,2.10) -- (2.42,2.46) -- (2.62,2.80) -- (2.62,2.80);
\draw[thick] (2.62,2.80) -- (2.01,2.85) -- (1.40,2.88) -- (1.23,2.89) -- (0.78,2.87) -- (0.39,2.82) -- (0.17,2.77) -- (-0.33,2.57) -- (-0.44,2.51) -- (-1.05,2.10) -- (-1.57,1.74);
\draw[thick] (-1.57,1.74) -- (-1.60,1.63) -- (-1.64,1.50) -- (-1.81,0.98) -- (-1.88,0.79) -- (-2.01,0.48) -- (-2.16,0.18) -- (-2.21,0.07) -- (-2.42,-0.29) -- (-2.62,-0.63) -- (-2.62,-0.63);
\draw[mid, dashed] (1.68,0.74) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.11}
\ra{1.14,2.84}{1.14,2.74}
\ra{0.66,2.73}{0.66,2.49}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.85);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.47}
\ra{0.86,2.46}{0.86,2.20}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.95);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.23}
\draw[dashed] (-0.95,-0.14) -- (-0.95,0.16);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,0.46);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.11);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.40}
\ra{1.55,1.88}{1.55,1.65}
\draw[dashed] (-0.06,-0.44) -- (-0.06,0.20);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.41);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.44);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 2.00$, \ $\mathbf w = (1.60, 1.20)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 2.908$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.9s = "true", 5.2s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.57,0.75);
\fill[white] (2.42,2.48) -- (2.62,2.81) -- (2.01,2.87) -- cycle;
\fill[white] (2.21,2.14) -- (2.42,2.48) -- (2.01,2.87) -- (1.40,2.92) -- cycle;
\fill[white] (2.01,1.78) -- (2.21,2.14) -- (1.40,2.92) -- (0.78,2.96) -- cycle;
\fill[white] (0.03,-0.69) -- (0.44,-0.49) -- (-1.60,1.48) -- (-1.74,1.01) -- cycle;
\fill[white] (0.44,-0.49) -- (0.54,-0.42) -- (-1.56,1.61) -- (-1.57,1.59) -- (-1.60,1.48) -- cycle;
\fill[white] (-0.17,-0.74) -- (0.03,-0.69) -- (-1.74,1.01) -- (-1.81,0.83) -- cycle;
\fill[white] (0.54,-0.42) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.56,1.61) -- cycle;
\fill[white] (1.93,1.63) -- (2.01,1.78) -- (0.78,2.96) -- (0.56,2.95) -- cycle;
\fill[white] (-0.56,-0.78) -- (-0.17,-0.74) -- (-1.81,0.83) -- (-1.93,0.54) -- cycle;
\fill[white] (1.81,1.34) -- (1.93,1.63) -- (0.56,2.95) -- (0.17,2.91) -- cycle;
\fill[white] (-0.78,-0.79) -- (-0.56,-0.78) -- (-1.93,0.54) -- (-2.01,0.40) -- cycle;
\fill[white] (1.05,0.07) -- (1.56,0.56) -- (-0.54,2.59) -- (-1.05,2.10) -- cycle;
\fill[white] (1.74,1.16) -- (1.81,1.34) -- (0.17,2.91) -- (-0.03,2.86) -- cycle;
\fill[white] (1.56,0.56) -- (1.57,0.58) -- (1.60,0.70) -- (-0.44,2.66) -- (-0.54,2.59) -- cycle;
\fill[white] (1.60,0.70) -- (1.74,1.16) -- (-0.03,2.86) -- (-0.44,2.66) -- cycle;
\fill[white] (-1.40,-0.75) -- (-0.78,-0.79) -- (-2.01,0.40) -- (-2.21,0.03) -- cycle;
\fill[white] (-2.01,-0.70) -- (-1.40,-0.75) -- (-2.21,0.03) -- (-2.42,-0.31) -- cycle;
\fill[white] (-2.62,-0.64) -- (-2.01,-0.70) -- (-2.42,-0.31) -- cycle;
\draw[mid] (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid] (-2.01,-0.70) -- (-2.41,-0.31);
\draw[mid] (-1.40,-0.75) -- (-2.21,0.03);
\draw[mid] (-0.78,-0.79) -- (-2.01,0.39);
\draw[mid] (-0.56,-0.78) -- (-1.93,0.54);
\draw[mid] (-0.17,-0.74) -- (-1.80,0.83);
\draw[mid] (0.03,-0.69) -- (-1.74,1.01);
\draw[mid] (0.44,-0.49) -- (-1.60,1.47);
\draw[mid] (0.54,-0.42) -- (-1.56,1.61);
\draw[mid] (1.56,0.57) -- (-0.54,2.59);
\draw[mid] (1.60,0.70) -- (-0.44,2.66);
\draw[mid] (1.74,1.16) -- (-0.03,2.86);
\draw[mid] (1.80,1.34) -- (0.17,2.91);
\draw[mid] (1.93,1.63) -- (0.56,2.95);
\draw[mid] (2.01,1.78) -- (0.78,2.96);
\draw[mid] (2.21,2.14) -- (1.40,2.92);
\draw[mid] (2.41,2.48) -- (2.01,2.87);
\draw[mid] (2.62,2.81) -- (2.62,2.81);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.64) -- (0.38,-0.43) -- (0.45,-0.33) -- (0.84,0.28) -- (1.23,0.88) -- (1.30,0.98) -- (1.61,1.28) -- (1.77,1.38) -- (1.83,1.41);
\draw[mid] (-1.57,-0.74) -- (-1.44,-0.71) -- (-0.97,-0.60) -- (-0.80,-0.55) -- (-0.51,-0.42) -- (-0.35,-0.32) -- (-0.04,-0.03) -- (0.03,0.07) -- (0.42,0.68) -- (0.81,1.29) -- (0.88,1.39) -- (1.19,1.68) -- (1.35,1.78) -- (1.64,1.91) -- (1.81,1.96) -- (2.16,2.05);
\draw[mid] (-2.49,-0.42) -- (-2.32,-0.40) -- (-1.86,-0.31) -- (-1.39,-0.20) -- (-1.22,-0.14) -- (-0.93,-0.01) -- (-0.77,0.08) -- (-0.46,0.38) -- (-0.39,0.48) -- (0.00,1.09) -- (0.39,1.69) -- (0.46,1.79) -- (0.77,2.09) -- (0.93,2.19) -- (1.22,2.32) -- (1.39,2.37) -- (1.86,2.48) -- (2.32,2.57) -- (2.49,2.60);
\draw[mid] (-2.16,0.12) -- (-1.81,0.21) -- (-1.64,0.26) -- (-1.35,0.39) -- (-1.19,0.49) -- (-0.88,0.78) -- (-0.81,0.88) -- (-0.42,1.49) -- (-0.03,2.10) -- (0.04,2.20) -- (0.35,2.49) -- (0.51,2.59) -- (0.80,2.72) -- (0.97,2.77) -- (1.44,2.88) -- (1.57,2.91);
\draw[mid] (-1.83,0.76) -- (-1.77,0.79) -- (-1.61,0.89) -- (-1.30,1.19) -- (-1.23,1.29) -- (-0.84,1.89) -- (-0.45,2.50) -- (-0.38,2.60) -- (-0.18,2.81);
\draw[thick] (-2.62,-0.64) -- (-2.01,-0.70) -- (-1.40,-0.75) -- (-0.78,-0.79) -- (-0.56,-0.78) -- (-0.17,-0.74) -- (0.03,-0.69) -- (0.44,-0.49) -- (0.54,-0.42) -- (1.05,0.07) -- (1.56,0.56) -- (1.57,0.58);
\draw[thick] (1.57,0.58) -- (1.60,0.70) -- (1.74,1.16) -- (1.81,1.34) -- (1.93,1.63) -- (2.01,1.78) -- (2.21,2.14) -- (2.42,2.48) -- (2.62,2.81) -- (2.62,2.81);
\draw[thick] (2.62,2.81) -- (2.01,2.87) -- (1.40,2.92) -- (0.78,2.96) -- (0.56,2.95) -- (0.17,2.91) -- (-0.03,2.86) -- (-0.44,2.66) -- (-0.54,2.59) -- (-1.05,2.10) -- (-1.56,1.61) -- (-1.57,1.59);
\draw[thick] (-1.57,1.59) -- (-1.60,1.48) -- (-1.74,1.01) -- (-1.81,0.83) -- (-1.93,0.54) -- (-2.01,0.40) -- (-2.21,0.03) -- (-2.42,-0.31) -- (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid, dashed] (1.57,0.75) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.23}
\ra{1.14,2.84}{1.14,2.81}
\ra{0.66,2.73}{0.66,2.62}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.69);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.53}
\ra{0.86,2.46}{0.86,2.33}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.82);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.29}
\draw[dashed] (-0.95,-0.14) -- (-0.95,0.01);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,0.31);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.16);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.55}
\ra{1.55,1.88}{1.55,1.78}
\draw[dashed] (-0.06,-0.44) -- (-0.06,0.05);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.49);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.57);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 2.83$, \ $\mathbf w = (2.26, 1.70)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 1.872$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 7s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.57,0.75);
\fill[white] (2.42,2.48) -- (2.62,2.81) -- (2.01,2.87) -- cycle;
\fill[white] (2.21,2.15) -- (2.42,2.48) -- (2.01,2.87) -- (1.40,2.93) -- cycle;
\fill[white] (0.33,-0.72) -- (0.44,-0.66) -- (-1.60,1.31) -- (-1.64,1.18) -- cycle;
\fill[white] (0.44,-0.66) -- (0.69,-0.43) -- (-1.41,1.59) -- (-1.57,1.43) -- (-1.60,1.31) -- cycle;
\fill[white] (-0.09,-0.83) -- (0.33,-0.72) -- (-1.64,1.18) -- (-1.78,0.80) -- cycle;
\fill[white] (2.01,1.81) -- (2.21,2.15) -- (1.40,2.93) -- (0.78,2.99) -- cycle;
\fill[white] (-0.17,-0.84) -- (-0.09,-0.83) -- (-1.78,0.80) -- (-1.81,0.74) -- cycle;
\fill[white] (0.69,-0.43) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.41,1.59) -- cycle;
\fill[white] (-0.78,-0.82) -- (-0.17,-0.84) -- (-1.81,0.74) -- (-2.01,0.36) -- cycle;
\fill[white] (1.81,1.43) -- (2.01,1.81) -- (0.78,2.99) -- (0.17,3.01) -- cycle;
\fill[white] (1.05,0.07) -- (1.41,0.58) -- (-0.69,2.60) -- (-1.05,2.10) -- cycle;
\fill[white] (1.78,1.37) -- (1.81,1.43) -- (0.17,3.01) -- (0.09,3.00) -- cycle;
\fill[white] (-1.40,-0.76) -- (-0.78,-0.82) -- (-2.01,0.36) -- (-2.21,0.02) -- cycle;
\fill[white] (1.64,0.99) -- (1.78,1.37) -- (0.09,3.00) -- (-0.33,2.89) -- cycle;
\fill[white] (1.41,0.58) -- (1.57,0.74) -- (1.60,0.86) -- (-0.44,2.83) -- (-0.69,2.60) -- cycle;
\fill[white] (1.60,0.86) -- (1.64,0.99) -- (-0.33,2.89) -- (-0.44,2.83) -- cycle;
\fill[white] (-2.01,-0.70) -- (-1.40,-0.76) -- (-2.21,0.02) -- (-2.42,-0.31) -- cycle;
\fill[white] (-2.62,-0.64) -- (-2.01,-0.70) -- (-2.42,-0.31) -- cycle;
\draw[mid] (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid] (-2.01,-0.70) -- (-2.41,-0.31);
\draw[mid] (-1.40,-0.76) -- (-2.21,0.02);
\draw[mid] (-0.78,-0.82) -- (-2.01,0.36);
\draw[mid] (-0.17,-0.84) -- (-1.80,0.74);
\draw[mid] (-0.09,-0.83) -- (-1.78,0.80);
\draw[mid] (0.33,-0.72) -- (-1.64,1.18);
\draw[mid] (0.44,-0.66) -- (-1.60,1.31);
\draw[mid] (0.69,-0.43) -- (-1.41,1.59);
\draw[mid] (1.41,0.58) -- (-0.69,2.60);
\draw[mid] (1.60,0.86) -- (-0.44,2.83);
\draw[mid] (1.64,0.99) -- (-0.33,2.89);
\draw[mid] (1.78,1.38) -- (0.09,3.00);
\draw[mid] (1.80,1.44) -- (0.17,3.01);
\draw[mid] (2.01,1.81) -- (0.78,2.99);
\draw[mid] (2.21,2.15) -- (1.40,2.93);
\draw[mid] (2.41,2.48) -- (2.01,2.87);
\draw[mid] (2.62,2.81) -- (2.62,2.81);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.78) -- (0.29,-0.69) -- (0.38,-0.60) -- (0.57,-0.31) -- (0.84,0.28) -- (1.11,0.87) -- (1.30,1.15) -- (1.39,1.24) -- (1.70,1.44) -- (1.77,1.47) -- (1.83,1.49);
\draw[mid] (-1.57,-0.75) -- (-1.44,-0.72) -- (-0.97,-0.64) -- (-0.51,-0.51) -- (-0.45,-0.49) -- (-0.13,-0.28) -- (-0.04,-0.19) -- (0.15,0.09) -- (0.42,0.68) -- (0.69,1.27) -- (0.88,1.55) -- (0.97,1.64) -- (1.28,1.85) -- (1.35,1.87) -- (1.81,2.00) -- (2.16,2.06);
\draw[mid] (-2.49,-0.43) -- (-2.32,-0.40) -- (-1.86,-0.32) -- (-1.39,-0.23) -- (-0.93,-0.11) -- (-0.86,-0.08) -- (-0.55,0.12) -- (-0.46,0.21) -- (-0.27,0.50) -- (0.00,1.09) -- (0.27,1.67) -- (0.46,1.96) -- (0.55,2.05) -- (0.86,2.25) -- (0.93,2.28) -- (1.39,2.40) -- (1.86,2.49) -- (2.32,2.57) -- (2.49,2.60);
\draw[mid] (-2.16,0.11) -- (-1.81,0.17) -- (-1.35,0.30) -- (-1.28,0.32) -- (-0.97,0.53) -- (-0.88,0.62) -- (-0.69,0.90) -- (-0.42,1.49) -- (-0.15,2.08) -- (0.04,2.36) -- (0.13,2.45) -- (0.45,2.66) -- (0.51,2.68) -- (0.97,2.81) -- (1.44,2.89) -- (1.57,2.92);
\draw[mid] (-1.83,0.68) -- (-1.77,0.70) -- (-1.70,0.73) -- (-1.39,0.93) -- (-1.30,1.02) -- (-1.11,1.31) -- (-0.84,1.89) -- (-0.57,2.48) -- (-0.38,2.77) -- (-0.29,2.86) -- (-0.18,2.95);
\draw[thick] (-2.62,-0.64) -- (-2.01,-0.70) -- (-1.40,-0.76) -- (-0.78,-0.82) -- (-0.17,-0.84) -- (-0.09,-0.83) -- (0.33,-0.72) -- (0.44,-0.66) -- (0.69,-0.43) -- (1.05,0.07) -- (1.41,0.58) -- (1.57,0.74);
\draw[thick] (1.57,0.74) -- (1.60,0.86) -- (1.64,0.99) -- (1.78,1.37) -- (1.81,1.43) -- (2.01,1.81) -- (2.21,2.15) -- (2.42,2.48) -- (2.62,2.81) -- (2.62,2.81);
\draw[thick] (2.62,2.81) -- (2.01,2.87) -- (1.40,2.93) -- (0.78,2.99) -- (0.17,3.01) -- (0.09,3.00) -- (-0.33,2.89) -- (-0.44,2.83) -- (-0.69,2.60) -- (-1.05,2.10) -- (-1.41,1.59) -- (-1.57,1.43);
\draw[thick] (-1.57,1.43) -- (-1.60,1.31) -- (-1.64,1.18) -- (-1.78,0.80) -- (-1.81,0.74) -- (-2.01,0.36) -- (-2.21,0.02) -- (-2.42,-0.31) -- (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid, dashed] (1.57,0.75) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.37}
\ra{1.14,2.84}{1.14,2.83}
\ra{0.66,2.73}{0.66,2.70}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.54);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.55}
\ra{0.86,2.46}{0.86,2.42}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.66);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.31}
\draw[dashed] (-0.95,-0.14) -- (-0.95,-0.08);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,0.14);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.18);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.72}
\ra{1.55,1.88}{1.55,1.85}
\draw[dashed] (-0.06,-0.44) -- (-0.06,-0.11);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.52);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.64);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 4.00$, \ $\mathbf w = (3.20, 2.40)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 1.091$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7s = "true", 7.3s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.47,0.76);
\fill[white] (2.42,2.48) -- (2.62,2.81) -- (2.01,2.87) -- cycle;
\fill[white] (2.21,2.15) -- (2.42,2.48) -- (2.01,2.87) -- (1.40,2.93) -- cycle;
\fill[white] (0.44,-0.81) -- (0.54,-0.74) -- (-1.56,1.28) -- (-1.57,1.27) -- (-1.60,1.16) -- cycle;
\fill[white] (0.24,-0.87) -- (0.44,-0.81) -- (-1.60,1.16) -- (-1.67,0.98) -- cycle;
\fill[white] (0.54,-0.74) -- (0.79,-0.44) -- (-1.30,1.58) -- (-1.56,1.28) -- cycle;
\fill[white] (-0.17,-0.88) -- (0.24,-0.87) -- (-1.67,0.98) -- (-1.81,0.70) -- cycle;
\fill[white] (2.01,1.82) -- (2.21,2.15) -- (1.40,2.93) -- (0.78,3.00) -- cycle;
\fill[white] (0.79,-0.44) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.30,1.58) -- cycle;
\fill[white] (-0.78,-0.83) -- (-0.17,-0.88) -- (-1.81,0.70) -- (-2.01,0.36) -- cycle;
\fill[white] (1.81,1.47) -- (2.01,1.82) -- (0.78,3.00) -- (0.17,3.05) -- cycle;
\fill[white] (1.05,0.07) -- (1.30,0.59) -- (-0.79,2.61) -- (-1.05,2.10) -- cycle;
\fill[white] (-1.40,-0.76) -- (-0.78,-0.83) -- (-2.01,0.36) -- (-2.21,0.02) -- cycle;
\fill[white] (1.67,1.19) -- (1.81,1.47) -- (0.17,3.05) -- (-0.24,3.04) -- cycle;
\fill[white] (1.30,0.59) -- (1.56,0.89) -- (-0.54,2.91) -- (-0.79,2.61) -- cycle;
\fill[white] (1.60,1.01) -- (1.67,1.19) -- (-0.24,3.04) -- (-0.44,2.98) -- cycle;
\fill[white] (1.56,0.89) -- (1.57,0.90) -- (1.60,1.01) -- (-0.44,2.98) -- (-0.54,2.91) -- cycle;
\fill[white] (-2.01,-0.70) -- (-1.40,-0.76) -- (-2.21,0.02) -- (-2.42,-0.31) -- cycle;
\fill[white] (-2.62,-0.64) -- (-2.01,-0.70) -- (-2.42,-0.31) -- cycle;
\draw[mid] (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid] (-2.01,-0.70) -- (-2.41,-0.31);
\draw[mid] (-1.40,-0.76) -- (-2.21,0.02);
\draw[mid] (-0.78,-0.83) -- (-2.01,0.35);
\draw[mid] (-0.17,-0.88) -- (-1.80,0.70);
\draw[mid] (0.24,-0.86) -- (-1.67,0.98);
\draw[mid] (0.44,-0.81) -- (-1.60,1.16);
\draw[mid] (0.54,-0.74) -- (-1.56,1.28);
\draw[mid] (0.79,-0.44) -- (-1.30,1.58);
\draw[mid] (1.30,0.59) -- (-0.79,2.61);
\draw[mid] (1.56,0.89) -- (-0.54,2.91);
\draw[mid] (1.60,1.01) -- (-0.44,2.98);
\draw[mid] (1.67,1.19) -- (-0.24,3.03);
\draw[mid] (1.80,1.48) -- (0.17,3.05);
\draw[mid] (2.01,1.82) -- (0.78,3.00);
\draw[mid] (2.21,2.15) -- (1.40,2.93);
\draw[mid] (2.41,2.48) -- (2.01,2.87);
\draw[mid] (2.62,2.81) -- (2.62,2.81);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.87) -- (0.23,-0.85) -- (0.38,-0.74) -- (0.45,-0.66) -- (0.65,-0.30) -- (0.84,0.28) -- (1.03,0.85) -- (1.23,1.21) -- (1.30,1.30) -- (1.45,1.40) -- (1.77,1.51) -- (1.83,1.52);
\draw[mid] (-1.57,-0.75) -- (-1.44,-0.72) -- (-0.97,-0.64) -- (-0.51,-0.55) -- (-0.19,-0.44) -- (-0.04,-0.34) -- (0.03,-0.25) -- (0.23,0.10) -- (0.42,0.68) -- (0.61,1.26) -- (0.81,1.62) -- (0.88,1.70) -- (1.03,1.81) -- (1.35,1.91) -- (1.81,2.00) -- (2.16,2.06);
\draw[mid] (-2.49,-0.43) -- (-2.32,-0.40) -- (-1.86,-0.32) -- (-1.39,-0.24) -- (-0.93,-0.15) -- (-0.61,-0.04) -- (-0.46,0.06) -- (-0.39,0.15) -- (-0.19,0.51) -- (0.00,1.09) -- (0.19,1.66) -- (0.39,2.02) -- (0.46,2.11) -- (0.61,2.21) -- (0.93,2.32) -- (1.39,2.41) -- (1.86,2.49) -- (2.32,2.57) -- (2.49,2.60);
\draw[mid] (-2.16,0.11) -- (-1.81,0.17) -- (-1.35,0.26) -- (-1.03,0.36) -- (-0.88,0.47) -- (-0.81,0.56) -- (-0.61,0.91) -- (-0.42,1.49) -- (-0.23,2.07) -- (-0.03,2.42) -- (0.04,2.51) -- (0.19,2.62) -- (0.51,2.72) -- (0.97,2.81) -- (1.44,2.89) -- (1.57,2.92);
\draw[mid] (-1.83,0.65) -- (-1.77,0.66) -- (-1.45,0.77) -- (-1.30,0.87) -- (-1.23,0.96) -- (-1.03,1.32) -- (-0.84,1.89) -- (-0.65,2.47) -- (-0.45,2.83) -- (-0.38,2.92) -- (-0.23,3.02) -- (-0.18,3.04);
\draw[thick] (-2.62,-0.64) -- (-2.01,-0.70) -- (-1.40,-0.76) -- (-0.78,-0.83) -- (-0.17,-0.88) -- (0.24,-0.87) -- (0.44,-0.81) -- (0.54,-0.74) -- (0.79,-0.44) -- (1.05,0.07) -- (1.30,0.59) -- (1.56,0.89) -- (1.57,0.90);
\draw[thick] (1.57,0.90) -- (1.60,1.01) -- (1.67,1.19) -- (1.81,1.47) -- (2.01,1.82) -- (2.21,2.15) -- (2.42,2.48) -- (2.62,2.81) -- (2.62,2.81);
\draw[thick] (2.62,2.81) -- (2.01,2.87) -- (1.40,2.93) -- (0.78,3.00) -- (0.17,3.05) -- (-0.24,3.04) -- (-0.44,2.98) -- (-0.54,2.91) -- (-0.79,2.61) -- (-1.05,2.10) -- (-1.30,1.58) -- (-1.56,1.28) -- (-1.57,1.27);
\draw[thick] (-1.57,1.27) -- (-1.60,1.16) -- (-1.67,0.98) -- (-1.81,0.70) -- (-2.01,0.36) -- (-2.21,0.02) -- (-2.42,-0.31) -- (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid, dashed] (1.47,0.76) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.54}
\ra{1.14,2.84}{1.14,2.84}
\ra{0.66,2.73}{0.66,2.72}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.44);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.55}
\ra{0.86,2.46}{0.86,2.45}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.49);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.31}
\draw[dashed] (-0.95,-0.14) -- (-0.95,-0.12);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,-0.01);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.18);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.86}
\ra{1.55,1.88}{1.55,1.88}
\draw[dashed] (-0.06,-0.44) -- (-0.06,-0.27);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.53);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.66);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 5.66$, \ $\mathbf w = (4.53, 3.39)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 0.553$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.3s = "true", 9.1s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.62,-0.64) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.36,0.77);
\fill[white] (2.42,2.48) -- (2.62,2.81) -- (2.01,2.87) -- cycle;
\fill[white] (2.21,2.15) -- (2.42,2.48) -- (2.01,2.87) -- (1.40,2.93) -- cycle;
\fill[white] (0.44,-0.90) -- (0.69,-0.76) -- (-1.41,1.27) -- (-1.57,1.15) -- (-1.60,1.07) -- cycle;
\fill[white] (0.69,-0.76) -- (0.87,-0.45) -- (-1.23,1.57) -- (-1.41,1.27) -- cycle;
\fill[white] (-0.17,-0.89) -- (0.44,-0.90) -- (-1.60,1.07) -- (-1.81,0.69) -- cycle;
\fill[white] (2.01,1.82) -- (2.21,2.15) -- (1.40,2.93) -- (0.78,3.00) -- cycle;
\fill[white] (0.87,-0.45) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.23,1.57) -- cycle;
\fill[white] (-0.78,-0.83) -- (-0.17,-0.89) -- (-1.81,0.69) -- (-2.01,0.35) -- cycle;
\fill[white] (1.81,1.48) -- (2.01,1.82) -- (0.78,3.00) -- (0.17,3.06) -- cycle;
\fill[white] (1.05,0.07) -- (1.23,0.60) -- (-0.87,2.62) -- (-1.05,2.10) -- cycle;
\fill[white] (-1.40,-0.76) -- (-0.78,-0.83) -- (-2.01,0.35) -- (-2.21,0.02) -- cycle;
\fill[white] (1.59,1.06) -- (1.81,1.48) -- (0.17,3.06) -- (-0.48,3.06) -- cycle;
\fill[white] (1.23,0.60) -- (1.41,0.91) -- (-0.69,2.93) -- (-0.87,2.62) -- cycle;
\fill[white] (1.41,0.91) -- (1.57,1.02) -- (1.59,1.06) -- (-0.48,3.06) -- (-0.69,2.93) -- cycle;
\fill[white] (-2.01,-0.70) -- (-1.40,-0.76) -- (-2.21,0.02) -- (-2.42,-0.31) -- cycle;
\fill[white] (-2.62,-0.64) -- (-2.01,-0.70) -- (-2.42,-0.31) -- cycle;
\draw[mid] (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid] (-2.01,-0.70) -- (-2.41,-0.31);
\draw[mid] (-1.40,-0.76) -- (-2.21,0.02);
\draw[mid] (-0.78,-0.83) -- (-2.01,0.35);
\draw[mid] (-0.17,-0.89) -- (-1.80,0.69);
\draw[mid] (0.44,-0.90) -- (-1.60,1.07);
\draw[mid] (0.69,-0.76) -- (-1.41,1.27);
\draw[mid] (0.87,-0.45) -- (-1.23,1.57);
\draw[mid] (1.23,0.60) -- (-0.87,2.62);
\draw[mid] (1.41,0.91) -- (-0.69,2.93);
\draw[mid] (1.59,1.07) -- (-0.48,3.06);
\draw[mid] (1.80,1.48) -- (0.17,3.06);
\draw[mid] (2.01,1.82) -- (0.78,3.00);
\draw[mid] (2.21,2.15) -- (1.40,2.93);
\draw[mid] (2.41,2.48) -- (2.01,2.87);
\draw[mid] (2.62,2.81) -- (2.62,2.81);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.91) -- (0.38,-0.84) -- (0.57,-0.64) -- (0.70,-0.29) -- (0.84,0.28) -- (0.98,0.84) -- (1.11,1.19) -- (1.27,1.37) -- (1.77,1.52) -- (1.83,1.53);
\draw[mid] (-1.57,-0.75) -- (-1.44,-0.72) -- (-0.97,-0.64) -- (-0.51,-0.56) -- (-0.04,-0.43) -- (0.15,-0.23) -- (0.28,0.11) -- (0.42,0.68) -- (0.56,1.25) -- (0.69,1.60) -- (0.85,1.77) -- (1.35,1.92) -- (1.81,2.00) -- (2.16,2.06);
\draw[mid] (-2.49,-0.43) -- (-2.32,-0.40) -- (-1.86,-0.32) -- (-1.39,-0.24) -- (-0.93,-0.16) -- (-0.46,-0.03) -- (-0.27,0.17) -- (-0.14,0.52) -- (0.00,1.09) -- (0.14,1.65) -- (0.27,2.00) -- (0.43,2.18) -- (0.93,2.33) -- (1.39,2.41) -- (1.86,2.49) -- (2.32,2.57) -- (2.49,2.60);
\draw[mid] (-2.16,0.11) -- (-1.81,0.17) -- (-1.35,0.25) -- (-0.88,0.38) -- (-0.69,0.57) -- (-0.56,0.92) -- (-0.42,1.49) -- (-0.28,2.06) -- (-0.15,2.41) -- (0.01,2.58) -- (0.51,2.73) -- (0.97,2.81) -- (1.44,2.89) -- (1.57,2.92);
\draw[mid] (-1.83,0.64) -- (-1.77,0.65) -- (-1.30,0.78) -- (-1.11,0.98) -- (-0.98,1.33) -- (-0.84,1.89) -- (-0.70,2.46) -- (-0.57,2.81) -- (-0.41,2.99) -- (-0.18,3.08);
\draw[thick] (-2.62,-0.64) -- (-2.01,-0.70) -- (-1.40,-0.76) -- (-0.78,-0.83) -- (-0.17,-0.89) -- (0.44,-0.90) -- (0.69,-0.76) -- (0.87,-0.45) -- (1.05,0.07) -- (1.23,0.60) -- (1.41,0.91) -- (1.57,1.02);
\draw[thick] (1.57,1.02) -- (1.59,1.06) -- (1.81,1.48) -- (2.01,1.82) -- (2.21,2.15) -- (2.42,2.48) -- (2.62,2.81) -- (2.62,2.81);
\draw[thick] (2.62,2.81) -- (2.01,2.87) -- (1.40,2.93) -- (0.78,3.00) -- (0.17,3.06) -- (-0.48,3.06) -- (-0.69,2.93) -- (-0.87,2.62) -- (-1.05,2.10) -- (-1.23,1.57) -- (-1.41,1.27) -- (-1.57,1.15);
\draw[thick] (-1.57,1.15) -- (-1.60,1.07) -- (-1.81,0.69) -- (-2.01,0.35) -- (-2.21,0.02) -- (-2.42,-0.31) -- (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid, dashed] (1.36,0.77) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.70}
\ra{1.14,2.84}{1.14,2.84}
\ra{0.66,2.73}{0.66,2.73}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.40);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.55}
\ra{0.86,2.46}{0.86,2.46}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.35);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.31}
\draw[dashed] (-0.95,-0.14) -- (-0.95,-0.13);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,-0.11);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.18);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.94}
\ra{1.55,1.88}{1.55,1.88}
\draw[dashed] (-0.06,-0.44) -- (-0.06,-0.37);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.53);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.67);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 8.00$, \ $\mathbf w = (6.40, 4.80)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 0.227$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.1s = "true", 9.4s = "false", 14.6s = "false", repeats}}}]
\draw[mid, thick] (-2.51,-0.65) -- (1.57,-1.06);
\draw[mid, thick] (1.57,-1.06) -- (2.62,0.64);
\draw[mid, thick] (2.62,0.64) -- (1.26,0.78);
\fill[white] (2.42,2.48) -- (2.62,2.81) -- (2.01,2.87) -- cycle;
\fill[white] (0.65,-0.91) -- (0.79,-0.77) -- (-1.30,1.25) -- (-1.45,1.12) -- cycle;
\fill[white] (0.44,-0.94) -- (0.65,-0.91) -- (-1.45,1.12) -- (-1.57,1.09) -- (-1.60,1.03) -- cycle;
\fill[white] (2.21,2.15) -- (2.42,2.48) -- (2.01,2.87) -- (1.40,2.93) -- cycle;
\fill[white] (0.79,-0.77) -- (0.92,-0.46) -- (-1.18,1.57) -- (-1.30,1.25) -- cycle;
\fill[white] (-0.17,-0.89) -- (0.44,-0.94) -- (-1.60,1.03) -- (-1.81,0.69) -- cycle;
\fill[white] (2.01,1.82) -- (2.21,2.15) -- (1.40,2.93) -- (0.78,3.00) -- cycle;
\fill[white] (0.92,-0.46) -- (1.05,0.07) -- (-1.05,2.10) -- (-1.18,1.57) -- cycle;
\fill[white] (-0.78,-0.83) -- (-0.17,-0.89) -- (-1.81,0.69) -- (-2.01,0.35) -- cycle;
\fill[white] (1.81,1.48) -- (2.01,1.82) -- (0.78,3.00) -- (0.17,3.06) -- cycle;
\fill[white] (1.05,0.07) -- (1.18,0.60) -- (-0.92,2.63) -- (-1.05,2.10) -- cycle;
\fill[white] (-1.40,-0.76) -- (-0.78,-0.83) -- (-2.01,0.35) -- (-2.21,0.02) -- cycle;
\fill[white] (1.60,1.14) -- (1.81,1.48) -- (0.17,3.06) -- (-0.44,3.11) -- cycle;
\fill[white] (1.18,0.60) -- (1.30,0.92) -- (-0.79,2.94) -- (-0.92,2.63) -- cycle;
\fill[white] (-2.01,-0.70) -- (-1.40,-0.76) -- (-2.21,0.02) -- (-2.42,-0.31) -- cycle;
\fill[white] (1.45,1.05) -- (1.57,1.08) -- (1.60,1.14) -- (-0.44,3.11) -- (-0.65,3.08) -- cycle;
\fill[white] (1.30,0.92) -- (1.45,1.05) -- (-0.65,3.08) -- (-0.79,2.94) -- cycle;
\fill[white] (-2.62,-0.64) -- (-2.01,-0.70) -- (-2.42,-0.31) -- cycle;
\draw[mid] (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid] (-2.01,-0.70) -- (-2.41,-0.31);
\draw[mid] (-1.40,-0.76) -- (-2.21,0.02);
\draw[mid] (-0.78,-0.83) -- (-2.01,0.35);
\draw[mid] (-0.17,-0.89) -- (-1.80,0.68);
\draw[mid] (0.44,-0.94) -- (-1.60,1.03);
\draw[mid] (0.64,-0.90) -- (-1.45,1.12);
\draw[mid] (0.79,-0.77) -- (-1.30,1.25);
\draw[mid] (0.92,-0.46) -- (-1.18,1.57);
\draw[mid] (1.18,0.60) -- (-0.92,2.63);
\draw[mid] (1.30,0.92) -- (-0.79,2.94);
\draw[mid] (1.45,1.05) -- (-0.64,3.07);
\draw[mid] (1.60,1.14) -- (-0.44,3.11);
\draw[mid] (1.80,1.49) -- (0.17,3.06);
\draw[mid] (2.01,1.82) -- (0.78,3.00);
\draw[mid] (2.21,2.15) -- (1.40,2.93);
\draw[mid] (2.41,2.48) -- (2.01,2.87);
\draw[mid] (2.62,2.81) -- (2.62,2.81);
\draw[thick] (1.05,0.07) -- (-1.05,2.10);
\draw[mid] (0.18,-0.92) -- (0.38,-0.88) -- (0.53,-0.80) -- (0.65,-0.63) -- (0.74,-0.28) -- (0.84,0.28) -- (0.94,0.84) -- (1.03,1.18) -- (1.15,1.35) -- (1.30,1.43) -- (1.77,1.52) -- (1.83,1.53);
\draw[mid] (-1.57,-0.75) -- (-1.44,-0.72) -- (-0.97,-0.64) -- (-0.51,-0.56) -- (-0.04,-0.47) -- (0.11,-0.39) -- (0.23,-0.22) -- (0.32,0.12) -- (0.42,0.68) -- (0.52,1.24) -- (0.61,1.58) -- (0.73,1.75) -- (0.88,1.83) -- (1.35,1.93) -- (1.81,2.00) -- (2.16,2.06);
\draw[mid] (-2.49,-0.43) -- (-2.32,-0.40) -- (-1.86,-0.32) -- (-1.39,-0.24) -- (-0.93,-0.16) -- (-0.46,-0.07) -- (-0.31,0.01) -- (-0.19,0.18) -- (-0.10,0.53) -- (0.00,1.09) -- (0.10,1.64) -- (0.19,1.99) -- (0.31,2.16) -- (0.46,2.24) -- (0.93,2.33) -- (1.39,2.41) -- (1.86,2.49) -- (2.32,2.57) -- (2.49,2.60);
\draw[mid] (-2.16,0.11) -- (-1.81,0.17) -- (-1.35,0.25) -- (-0.88,0.34) -- (-0.73,0.42) -- (-0.61,0.59) -- (-0.52,0.93) -- (-0.42,1.49) -- (-0.32,2.05) -- (-0.23,2.39) -- (-0.11,2.56) -- (0.04,2.64) -- (0.51,2.73) -- (0.97,2.81) -- (1.44,2.89) -- (1.57,2.92);
\draw[mid] (-1.83,0.64) -- (-1.77,0.65) -- (-1.30,0.74) -- (-1.15,0.82) -- (-1.03,0.99) -- (-0.94,1.34) -- (-0.84,1.89) -- (-0.74,2.45) -- (-0.65,2.80) -- (-0.53,2.97) -- (-0.38,3.05) -- (-0.18,3.09);
\draw[thick] (-2.62,-0.64) -- (-2.01,-0.70) -- (-1.40,-0.76) -- (-0.78,-0.83) -- (-0.17,-0.89) -- (0.44,-0.94) -- (0.65,-0.91) -- (0.79,-0.77) -- (0.92,-0.46) -- (1.05,0.07) -- (1.18,0.60) -- (1.30,0.92) -- (1.45,1.05) -- (1.57,1.08);
\draw[thick] (1.57,1.08) -- (1.60,1.14) -- (1.81,1.48) -- (2.01,1.82) -- (2.21,2.15) -- (2.42,2.48) -- (2.62,2.81) -- (2.62,2.81);
\draw[thick] (2.62,2.81) -- (2.01,2.87) -- (1.40,2.93) -- (0.78,3.00) -- (0.17,3.06) -- (-0.44,3.11) -- (-0.65,3.08) -- (-0.79,2.94) -- (-0.92,2.63) -- (-1.05,2.10) -- (-1.18,1.57) -- (-1.30,1.25) -- (-1.45,1.12) -- (-1.57,1.09);
\draw[thick] (-1.57,1.09) -- (-1.60,1.03) -- (-1.81,0.69) -- (-2.01,0.35) -- (-2.21,0.02) -- (-2.42,-0.31) -- (-2.62,-0.64) -- (-2.62,-0.64);
\draw[mid, dashed] (-2.62,-0.64) -- (-2.51,-0.65);
\draw[mid, dashed] (1.26,0.78) -- (-1.57,1.06);
\draw[mid, dashed] (-1.57,1.06) -- (-2.62,-0.64);
\ra{-0.37,2.87}{-0.37,2.81}
\ra{1.14,2.84}{1.14,2.84}
\ra{0.66,2.73}{0.66,2.73}
\draw[dashed] (-1.15,0.38) -- (-1.15,0.39);
\bh{-1.15,0.38}
\ra{1.46,2.55}{1.46,2.55}
\ra{0.86,2.46}{0.86,2.46}
\draw[dashed] (-0.64,0.23) -- (-0.64,0.27);
\bh{-0.64,0.23}
\ra{1.80,2.31}{1.80,2.31}
\draw[dashed] (-0.95,-0.14) -- (-0.95,-0.13);
\bh{-0.95,-0.14}
\draw[dashed] (-0.35,-0.17) -- (-0.35,-0.16);
\bh{-0.35,-0.17}
\draw[dashed] (-1.84,-0.18) -- (-1.84,-0.18);
\bh{-1.84,-0.18}
\ra{0.79,1.98}{0.79,1.97}
\ra{1.55,1.88}{1.55,1.88}
\draw[dashed] (-0.06,-0.44) -- (-0.06,-0.42);
\bh{-0.06,-0.44}
\draw[dashed] (-1.11,-0.53) -- (-1.11,-0.53);
\bh{-1.11,-0.53}
\draw[dashed] (-0.56,-0.67) -- (-0.56,-0.67);
\bh{-0.56,-0.67}
\node[anchor=west] at (4.60,3.2) {surface $\sigma(\mathbf w^T\mathbf x)$, \ $\mathbf w = c\,\mathbf w_0$, \ $b = 0$};
\node[anchor=west] at (4.60,2.55) {$c = 11.31$, \ $\mathbf w = (9.05, 6.79)$};
\node[anchor=west] at (4.60,1.9) {NLL $= 0.069$};
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.4s = "true", 11.2s = "false", 14.6s = "false", repeats}}}]
\node[anchor=west] at (-4.3,-3.30) {Doubling $c$ keeps the boundary and steepens the surface. Every gap shrinks.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.2s = "true", 14.6s = "true", repeats}}}]
\node[anchor=west] at (-4.3,-3.30) {On separable data the NLL falls toward $0$ but never reaches it. No finite $\mathbf w$ minimizes it.};
\end{scope}
\draw (4.70,-2.3) -- (9.10,-2.3);
\node at (6.90,0.85) {\footnotesize NLL for each $c$};
\node[below] at (5.20,-2.3) {\footnotesize $1$};
\node[below] at (6.05,-2.3) {\footnotesize $2$};
\node[below] at (6.90,-2.3) {\footnotesize $4$};
\node[below] at (7.75,-2.3) {\footnotesize $8$};
\node[below] at (8.60,-2.3) {\footnotesize $16$};
\node[anchor=west] at (9.15,-2.60) {\footnotesize $c$};
\draw[->] (-2.62,-0.64) -- (-2.62,2.01);
\draw (-2.62,-0.64) -- (-2.72,-0.64) node[left] {\footnotesize $0$};
\draw (-2.62,0.45) -- (-2.72,0.45) node[left] {\footnotesize $0.5$};
\draw (-2.62,1.53) -- (-2.72,1.53) node[left] {\footnotesize $1$};
\node[above] at (-2.62,2.01) {\footnotesize $\sigma$};
\end{tikzpicture}
\end{document}(Reading the Coefficients) The factor is an odds ratio, and bounds the slope of the probability.
The slope of the probability is . It peaks at , where it equals . Gelman and Hill (2007) call this the “divide by 4” rule. Near or , the same barely moves the probability, although it still multiplies the odds by . Coefficients are comparable across features only when the features share a scale, so standardize them first. With correlated features, individual can change sign between samples, as in multiple linear regression.
(Newton Is Weighted Least Squares) Each Newton step solves a weighted least-squares problem, which explains the name IRLS.
Define the working response . The Newton step then becomes . This is least squares of on with weights . Points with near get the largest weights. IRLS usually converges in under ten steps, and quadratically near the solution. Each step costs for the weighted normal equations. For large , quasi-Newton methods such as L-BFGS or SGD replace it. Separable or nearly separable data make nearly singular, and the Newton steps blow up.
(Probabilities Match Counts) At the maximum likelihood estimate, the fitted probabilities match the observed labels along every feature.
The condition says for every column . The intercept column gives . The average predicted probability on the training set therefore equals the observed rate of positives. The same balance holds within any group that a binary feature marks. This is a weak form of calibration. It says nothing about groups that the features do not encode, and it holds only on the training data. 2.2.4. Log Loss covers calibration checks on new data.
(Why Not Squared Error) Cross-entropy keeps a large gradient on confident mistakes, and squared error on the probability does not.
The squared error has gradient with respect to . When a positive example gets , the factor is near zero, so the worst mistakes barely change the weights. Squared error composed with the sigmoid is also not convex in . Cross-entropy cancels the factor and leaves the gradient , which is near for that example. Prince (Understanding Deep Learning, sec. 5.4) derives the same loss for networks with a sigmoid output.
Derivation
We want the sigmoid from the log-odds, then the gradient and the Hessian. Setting and solving for gives
Differentiating gives . Write , with the bias inside . Substituting into the loss of sample gives
Implementations use this form, since it never takes the logarithm of a number that has rounded to . Its derivative is . By the chain rule, , and summing over samples gives . Differentiating once more gives , and the sum is . For any vector , , which proves convexity.
Examples
(Easy) Odds of a Hospital Readmission
A hospital predicts 30-day readmission with . Here is the number of prior admissions and is age in decades. A patient is 60 years old and has two prior admissions.
What is the predicted probability? How do the odds and the probability change with one more prior admission? , so , and the odds are . One more admission multiplies the odds by , giving odds and . The probability rises by . The slope at this patient is , close to the bound , because is near . A patient with would gain only about per admission at first.
The score is
(Medium) Newton's Method on Exam Data
Four students studied hours. The second and fourth passed, so . The model is , started at .
Take one Newton step by hand. Where does the iteration end? , so . The Newton step becomes , four times the least-squares fit of on . Here and . The least-squares fit is , so the step goes to . The loss falls from to . Three more steps converge to and , with loss . The fitted probabilities are . They sum to , the number of students who passed.
At the start every
(Hard) Separable Exam Data
Now the two students with the most hours passed, so for .
Show that the unpenalized loss has no minimizer. Then fit with the penalty for . Take and , which puts the boundary at . The scores are , each with the correct sign. The loss is . It equals at , at and at . It approaches but never reaches it, so no finite weights minimize it. With , numerical minimization gives and . By symmetry the boundary stays at . The fitted probabilities are . A weaker penalty, , gives and end probabilities and . A larger keeps the weights smaller and the probabilities farther from and .
See Also
- 4.3a. Softmax Regression, the extension to classes.
- 4.2. Linear Discriminants, where LDA produces the same linear log-odds from Gaussian class densities.
- 3.8.3 Bayesian Logistic Regression, for the posterior over and the Laplace approximation.
- 2.2.4. Log Loss, the binary cross-entropy used as an evaluation metric.
- 1. Shannon Entropy, for the information-theoretic meaning of cross-entropy.