Linear Discriminants

A linear discriminant is a function of the input , with weight vector and bias . A two-class rule assigns to class when and to class when . The sign of decides the class. The decision boundary is the set , a -dimensional hyperplane. Its geometry has three parts:

  • Orientation: is normal to the boundary. Two boundary points satisfy , so .
  • Signed distance: a point lies at signed distance from the boundary. It is positive on the class- side, the side points to.
  • Offset: the origin has , so the boundary lies at distance from the origin. For a fixed , changing shifts the boundary parallel to itself.

With classes, there are three common constructions (Bishop, PRML, sec. 4.1.2):

  • discriminants with argmax: each class gets , and the rule predicts . Classes and meet on the hyperplane . Every decision region is convex.
  • One-vs-rest: binary classifiers each separate one class from all others. Some inputs are claimed by two classes or by none.
  • One-vs-one: binary classifiers each separate a pair of classes and then vote. Some inputs end in a tied vote.

Linear discriminant analysis (LDA) obtains from the Bayes classifier. It assumes Gaussian classes with a shared covariance, , with priors . For two classes the posterior log-odds are then linear in , with

Here is the mean of class and is the shared covariance. In practice , and is the sample mean of the points in class . The estimate of is the pooled within-class covariance. With classes, LDA predicts the class with the largest score

which is linear in . Quadratic discriminant analysis (QDA) gives each class its own covariance . Its score

is quadratic in , where is the determinant, so QDA boundaries are curved.

Fisher’s linear discriminant drops the Gaussian assumption. It picks the direction along which the projected class means are far apart compared with the spread within each class:

Here are the class sample means and is the within-class scatter matrix. This is the LDA direction. Fisher’s criterion fixes only the direction, so the threshold is chosen separately. Other linear classifiers fit and by other criteria: the perceptron, logistic regression and support vector machines.

Intuition

A discriminant is a function that tells classes apart. A linear one computes a weighted sum of the features plus a constant. The weighted sum measures how far the input lies along the direction . The bias sets the cut-off on that scale. All inputs on one side of the cut-off get the same class. The boundary is therefore a flat hyperplane perpendicular to .

Linear discriminants differ in how they choose and . LDA assumes Gaussian classes with a shared covariance and reads the boundary off Bayes’ rule. Fisher’s method searches for the direction along which the projected classes sit farthest apart relative to their spread. Both reach the same direction, . The raw mean difference points from one class center to the other. The inverse covariance tilts it away from directions where the classes are noisy.

The gray plane shows above every input. The boundary is the line where the plane crosses zero. The distance to the boundary is , which differs from when .

\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\newcommand{\pa}[1]{\filldraw[draw=black, fill=hot] (#1) circle (2.6pt);}
\newcommand{\pb}[1]{\filldraw[draw=black, fill=cold] (#1) circle (2.6pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}, xshift=4.6cm]
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 2.2s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-0.52,-1.71) -- (4.21,-0.21) -- (0.52,1.71) -- (-4.21,0.21) -- cycle;
\draw[->] (-0.44,-1.46) -- (0.23,-1.24);
\node[fill=white, inner sep=1pt] at (0.46,-1.17) {\footnotesize $x_1$};
\draw[->] (-0.44,-1.46) -- (-0.96,-1.18);
\node[fill=white, inner sep=1pt] at (-1.15,-1.09) {\footnotesize $x_2$};
\pa{-0.32,1.25}
\pa{0.09,1.14}
\pa{-0.51,1.05}
\pa{-0.91,0.96}
\pa{-1.39,0.94}
\pa{0.24,0.92}
\pa{-0.26,0.89}
\pa{-0.61,0.76}
\pa{-1.07,0.73}
\pa{0.03,0.72}
\pb{-0.76,0.08}
\pb{0.05,0.05}
\pb{0.98,0.02}
\pb{-1.41,-0.06}
\pb{-0.57,-0.26}
\pb{-1.03,-0.36}
\pb{-0.49,-0.47}
\pb{0.17,-0.51}
\pb{-1.11,-0.60}
\pb{-0.37,-0.69}
\node[anchor=west] at (-4.6,-4.59) {Two classes on the input plane $(x_1, x_2)$. Red: class $1$. Blue: class $0$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.2s = "true", 2.44s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-0.63,-1.71) -- (4.20,-0.26) -- (0.63,1.71) -- (-4.20,0.26) -- cycle;
\draw[mid, dashed] (-2.68,-0.59) -- (-3.39,0.13);
\draw[mid, dashed] (2.31,-0.81) -- (3.44,0.04);
\draw[mid, dashed] (-0.33,-1.54) -- (-2.59,0.74);
\draw[mid, dashed] (-0.05,-1.54) -- (2.20,0.16);
\draw[mid, dashed] (0.83,-1.30) -- (-0.95,0.51);
\draw[mid, dashed] (-1.29,-1.43) -- (0.97,0.27);
\draw[mid, dashed] (1.87,-0.93) -- (0.57,0.39);
\draw[mid, dashed] (-2.04,-0.95) -- (-0.11,0.51);
\draw[mid, dashed] (2.92,-0.57) -- (2.20,0.16);
\draw[mid, dashed] (-2.80,-0.47) -- (-1.35,0.62);
\draw[mid, dashed] (4.08,-0.32) -- (3.84,-0.08);
\draw[mid, dashed] (-3.71,-0.11) -- (-2.59,0.74);
\draw[->] (-0.54,-1.45) -- (0.15,-1.25);
\node[fill=white, inner sep=1pt] at (0.39,-1.17) {\footnotesize $x_1$};
\draw[->] (-0.54,-1.45) -- (-1.04,-1.17);
\node[fill=white, inner sep=1pt] at (-1.22,-1.07) {\footnotesize $x_2$};
\pa{-0.23,1.26}
\pa{0.17,1.14}
\pa{-0.44,1.05}
\pa{-0.85,0.97}
\pa{-1.32,0.95}
\pa{0.30,0.91}
\pa{-0.20,0.90}
\pa{-0.56,0.77}
\pa{-1.02,0.74}
\pa{0.08,0.72}
\pb{-0.75,0.09}
\pb{0.05,0.05}
\pb{0.99,0.00}
\pb{-1.41,-0.04}
\pb{-0.58,-0.26}
\pb{-1.05,-0.34}
\pb{-0.52,-0.46}
\pb{0.14,-0.52}
\pb{-1.15,-0.59}
\pb{-0.42,-0.69}
\draw[mid, thick] (-0.63,-4.08) -- (-4.20,-0.47);
\draw[mid, thick] (-0.63,-4.08) -- (4.20,-0.44);
\draw[mid] (0.17,-3.47) -- (-2.68,-0.59);
\draw[mid] (-1.23,-3.48) -- (2.31,-0.81);
\draw[mid] (3.44,0.04) -- (3.60,0.16);
\draw[mid] (0.98,-2.87) -- (-0.33,-1.54);
\draw[mid] (-1.82,-2.88) -- (-0.05,-1.54);
\draw[mid] (2.20,0.16) -- (3.01,0.76);
\draw[mid] (1.78,-2.26) -- (0.83,-1.30);
\draw[mid] (-0.95,0.51) -- (-1.78,1.35);
\draw[mid] (-2.41,-2.28) -- (-1.29,-1.43);
\draw[mid] (0.97,0.27) -- (2.41,1.36);
\draw[mid] (2.59,-1.65) -- (1.87,-0.93);
\draw[mid] (0.57,0.39) -- (-0.98,1.95);
\draw[mid] (-3.01,-1.68) -- (-2.04,-0.95);
\draw[mid] (-0.11,0.51) -- (1.82,1.97);
\draw[mid] (3.39,-1.05) -- (2.92,-0.57);
\draw[mid] (2.20,0.16) -- (-0.17,2.56);
\draw[mid] (-3.60,-1.08) -- (-2.80,-0.47);
\draw[mid] (-1.35,0.62) -- (1.23,2.57);
\draw[mid, thick] (4.20,-0.44) -- (4.08,-0.32);
\draw[mid, thick] (3.84,-0.08) -- (0.63,3.17);
\draw[mid, thick] (-4.20,-0.47) -- (-3.71,-0.11);
\draw[mid, thick] (-2.59,0.74) -- (0.63,3.17);
\node[anchor=west] at (-4.6,-4.59) {Above each input $\mathbf x$, the gray plane has height $g(\mathbf x) = \mathbf w^T\mathbf x + b$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.44s = "true", 2.68s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-0.88,-1.69) -- (4.15,-0.36) -- (0.88,1.69) -- (-4.15,0.36) -- cycle;
\draw[mid, dashed] (-2.55,-0.65) -- (-3.31,0.21);
\draw[mid, dashed] (2.26,-0.87) -- (3.44,-0.04);
\draw[mid, dashed] (-0.40,-1.54) -- (-2.47,0.80);
\draw[mid, dashed] (0.04,-1.42) -- (2.22,0.10);
\draw[mid, dashed] (0.76,-1.32) -- (-0.87,0.53);
\draw[mid, dashed] (-1.34,-1.40) -- (1.01,0.25);
\draw[mid, dashed] (1.82,-0.98) -- (0.62,0.38);
\draw[mid, dashed] (-2.05,-0.90) -- (-0.04,0.51);
\draw[mid, dashed] (2.88,-0.64) -- (2.22,0.10);
\draw[mid, dashed] (-2.77,-0.40) -- (-1.26,0.66);
\draw[mid, dashed] (4.04,-0.42) -- (3.82,-0.17);
\draw[mid, dashed] (-3.65,-0.02) -- (-2.47,0.80);
\draw[->] (-0.75,-1.43) -- (-0.04,-1.25);
\node[fill=white, inner sep=1pt] at (0.21,-1.18) {\footnotesize $x_1$};
\draw[->] (-0.75,-1.43) -- (-1.21,-1.14);
\node[fill=white, inner sep=1pt] at (-1.37,-1.04) {\footnotesize $x_2$};
\pa{-0.05,1.26}
\pa{0.34,1.14}
\pa{-0.28,1.06}
\pa{-0.70,0.99}
\pa{-1.18,0.98}
\pa{0.43,0.90}
\pa{-0.07,0.90}
\pa{-0.45,0.78}
\pa{-0.91,0.76}
\pa{0.19,0.72}
\pb{-0.74,0.11}
\pb{0.06,0.05}
\pb{-1.41,-0.01}
\pb{0.98,-0.02}
\pb{-0.62,-0.24}
\pb{-1.10,-0.32}
\pb{-0.59,-0.45}
\pb{0.06,-0.52}
\pb{-1.24,-0.56}
\pb{-0.52,-0.68}
\draw[mid, thick] (-0.88,-4.06) -- (-4.15,-0.37);
\draw[mid, thick] (-0.88,-4.06) -- (4.15,-0.54);
\draw[mid] (-0.04,-3.48) -- (-2.55,-0.65);
\draw[mid] (-1.43,-3.45) -- (2.26,-0.87);
\draw[mid] (3.44,-0.04) -- (3.61,0.07);
\draw[mid] (0.80,-2.89) -- (-0.40,-1.54);
\draw[mid] (-1.97,-2.83) -- (0.04,-1.42);
\draw[mid] (2.22,0.10) -- (3.06,0.69);
\draw[mid] (1.63,-2.30) -- (0.76,-1.32);
\draw[mid] (-0.87,0.53) -- (-1.63,1.39);
\draw[mid] (-2.52,-2.22) -- (-1.34,-1.40);
\draw[mid] (1.01,0.25) -- (2.52,1.30);
\draw[mid] (2.47,-1.72) -- (1.82,-0.98);
\draw[mid] (0.62,0.38) -- (-0.80,1.98);
\draw[mid] (-3.06,-1.60) -- (-2.05,-0.90);
\draw[mid] (-0.04,0.51) -- (1.97,1.92);
\draw[mid] (3.31,-1.13) -- (2.88,-0.64);
\draw[mid] (2.22,0.10) -- (0.04,2.56);
\draw[mid] (-3.61,-0.99) -- (-2.77,-0.40);
\draw[mid] (-1.26,0.66) -- (1.43,2.53);
\draw[mid, thick] (4.15,-0.54) -- (4.04,-0.42);
\draw[mid, thick] (3.82,-0.17) -- (0.88,3.15);
\draw[mid, thick] (-4.15,-0.37) -- (-3.65,-0.02);
\draw[mid, thick] (-2.47,0.80) -- (0.88,3.15);
\node[anchor=west] at (-4.6,-4.59) {Above each input $\mathbf x$, the gray plane has height $g(\mathbf x) = \mathbf w^T\mathbf x + b$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.68s = "true", 2.92s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.13,-1.66) -- (4.09,-0.46) -- (1.13,1.66) -- (-4.09,0.46) -- cycle;
\draw[mid, dashed] (-2.43,-0.71) -- (-3.22,0.29);
\draw[mid, dashed] (2.20,-0.92) -- (3.42,-0.13);
\draw[mid, dashed] (-0.48,-1.53) -- (-2.35,0.86);
\draw[mid, dashed] (-0.03,-1.42) -- (2.23,0.05);
\draw[mid, dashed] (0.59,-1.21) -- (-0.79,0.55);
\draw[mid, dashed] (-1.39,-1.36) -- (1.04,0.22);
\draw[mid, dashed] (1.76,-1.02) -- (0.67,0.36);
\draw[mid, dashed] (-2.23,-0.96) -- (0.03,0.51);
\draw[mid, dashed] (2.83,-0.71) -- (2.23,0.05);
\draw[mid, dashed] (-2.90,-0.45) -- (-1.16,0.69);
\draw[mid, dashed] (3.99,-0.52) -- (3.79,-0.27);
\draw[mid, dashed] (-3.57,0.07) -- (-2.35,0.86);
\draw[->] (-0.96,-1.41) -- (-0.22,-1.24);
\node[fill=white, inner sep=1pt] at (0.04,-1.18) {\footnotesize $x_1$};
\draw[->] (-0.96,-1.41) -- (-1.38,-1.11);
\node[fill=white, inner sep=1pt] at (-1.53,-1.01) {\footnotesize $x_2$};
\pa{0.14,1.26}
\pa{0.50,1.13}
\pa{-0.12,1.07}
\pa{-1.03,1.01}
\pa{-0.56,1.00}
\pa{0.07,0.90}
\pa{0.56,0.89}
\pa{-0.33,0.79}
\pa{-0.80,0.78}
\pa{0.29,0.71}
\pb{-0.72,0.13}
\pb{0.07,0.05}
\pb{-1.41,0.03}
\pb{0.98,-0.04}
\pb{-0.65,-0.23}
\pb{-1.15,-0.29}
\pb{-0.66,-0.43}
\pb{-0.01,-0.52}
\pb{-1.32,-0.53}
\pb{-0.62,-0.66}
\draw[mid, thick] (-1.13,-4.04) -- (-4.09,-0.27);
\draw[mid, thick] (-1.13,-4.04) -- (4.09,-0.64);
\draw[mid] (-0.26,-3.47) -- (-2.43,-0.71);
\draw[mid] (-1.62,-3.41) -- (2.20,-0.92);
\draw[mid] (3.42,-0.13) -- (3.60,-0.01);
\draw[mid] (0.61,-2.91) -- (-0.48,-1.53);
\draw[mid] (-2.12,-2.78) -- (-0.03,-1.42);
\draw[mid] (2.23,0.05) -- (3.10,0.61);
\draw[mid] (1.48,-2.34) -- (0.59,-1.21);
\draw[mid] (-0.79,0.55) -- (-1.48,1.43);
\draw[mid] (-2.61,-2.16) -- (-1.39,-1.36);
\draw[mid] (1.04,0.22) -- (2.61,1.24);
\draw[mid] (2.35,-1.77) -- (1.76,-1.02);
\draw[mid] (0.67,0.36) -- (-0.61,1.99);
\draw[mid] (-3.10,-1.53) -- (-2.23,-0.96);
\draw[mid] (0.03,0.51) -- (2.12,1.87);
\draw[mid] (3.22,-1.21) -- (2.83,-0.71);
\draw[mid] (2.23,0.05) -- (0.26,2.56);
\draw[mid] (-3.60,-0.90) -- (-2.90,-0.45);
\draw[mid] (-1.16,0.69) -- (1.62,2.50);
\draw[mid, thick] (4.09,-0.64) -- (3.99,-0.52);
\draw[mid, thick] (3.79,-0.27) -- (1.13,3.13);
\draw[mid, thick] (-4.09,-0.27) -- (-3.57,0.07);
\draw[mid, thick] (-2.35,0.86) -- (1.13,3.13);
\node[anchor=west] at (-4.6,-4.59) {Above each input $\mathbf x$, the gray plane has height $g(\mathbf x) = \mathbf w^T\mathbf x + b$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.92s = "true", 5.32s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.24,-1.65) -- (4.06,-0.50) -- (1.24,1.65) -- (-4.06,0.50) -- cycle;
\draw[mid, dashed] (-2.33,-0.81) -- (-3.17,0.33);
\draw[mid, dashed] (2.18,-0.94) -- (3.41,-0.17);
\draw[mid, dashed] (-0.51,-1.52) -- (-2.29,0.89);
\draw[mid, dashed] (-0.06,-1.42) -- (2.24,0.02);
\draw[mid, dashed] (0.56,-1.22) -- (-0.75,0.56);
\draw[mid, dashed] (-1.59,-1.46) -- (1.06,0.21);
\draw[mid, dashed] (1.73,-1.04) -- (0.70,0.35);
\draw[mid, dashed] (-2.24,-0.94) -- (0.06,0.51);
\draw[mid, dashed] (2.80,-0.74) -- (2.24,0.02);
\draw[mid, dashed] (-2.88,-0.41) -- (-1.12,0.70);
\draw[mid, dashed] (3.96,-0.56) -- (3.78,-0.31);
\draw[mid, dashed] (-3.53,0.11) -- (-2.29,0.89);
\draw[->] (-1.05,-1.40) -- (-0.30,-1.24);
\node[fill=white, inner sep=1pt] at (-0.04,-1.18) {\footnotesize $x_1$};
\draw[->] (-1.05,-1.40) -- (-1.45,-1.10);
\node[fill=white, inner sep=1pt] at (-1.59,-0.99) {\footnotesize $x_2$};
\pa{0.22,1.26}
\pa{0.58,1.12}
\pa{-0.05,1.07}
\pa{-0.96,1.02}
\pa{-0.49,1.01}
\pa{0.13,0.90}
\pa{0.62,0.89}
\pa{-0.28,0.79}
\pa{-0.74,0.79}
\pa{0.34,0.71}
\pb{-0.71,0.13}
\pb{0.07,0.05}
\pb{-1.41,0.04}
\pb{0.98,-0.05}
\pb{-0.67,-0.22}
\pb{-1.16,-0.28}
\pb{-0.69,-0.43}
\pb{-1.35,-0.52}
\pb{-0.05,-0.52}
\pb{-0.66,-0.66}
\draw[mid, thick] (-1.24,-4.03) -- (-4.06,-0.23);
\draw[mid, thick] (-1.24,-4.03) -- (4.06,-0.69);
\draw[mid] (-0.36,-3.47) -- (-2.33,-0.81);
\draw[mid] (-1.71,-3.39) -- (2.18,-0.94);
\draw[mid] (3.41,-0.17) -- (3.59,-0.05);
\draw[mid] (0.53,-2.91) -- (-0.51,-1.52);
\draw[mid] (-2.18,-2.76) -- (-0.06,-1.42);
\draw[mid] (2.24,0.02) -- (3.12,0.58);
\draw[mid] (1.41,-2.36) -- (0.56,-1.22);
\draw[mid] (-0.75,0.56) -- (-1.41,1.44);
\draw[mid] (-2.65,-2.13) -- (-1.59,-1.46);
\draw[mid] (1.06,0.21) -- (2.65,1.21);
\draw[mid] (2.29,-1.80) -- (1.73,-1.04);
\draw[mid] (0.70,0.35) -- (-0.53,2.00);
\draw[mid] (-3.12,-1.49) -- (-2.24,-0.94);
\draw[mid] (0.06,0.51) -- (2.18,1.85);
\draw[mid] (3.17,-1.24) -- (2.80,-0.74);
\draw[mid] (2.24,0.02) -- (0.36,2.56);
\draw[mid] (-3.59,-0.86) -- (-2.88,-0.41);
\draw[mid] (-1.12,0.70) -- (1.71,2.48);
\draw[mid, thick] (4.06,-0.69) -- (3.96,-0.56);
\draw[mid, thick] (3.78,-0.31) -- (1.24,3.11);
\draw[mid, thick] (-4.06,-0.23) -- (-3.53,0.11);
\draw[mid, thick] (-2.29,0.89) -- (1.24,3.11);
\node[anchor=west] at (-4.6,-4.59) {Above each input $\mathbf x$, the gray plane has height $g(\mathbf x) = \mathbf w^T\mathbf x + b$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.32s = "true", 7.92s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.24,-1.65) -- (4.06,-0.50) -- (1.24,1.65) -- (-4.06,0.50) -- cycle;
\draw[mid, dashed] (-2.33,-0.81) -- (-3.17,0.33);
\draw[mid, dashed] (2.18,-0.94) -- (3.41,-0.17);
\draw[mid, dashed] (-0.51,-1.52) -- (-2.29,0.89);
\draw[mid, dashed] (-0.06,-1.42) -- (2.24,0.02);
\draw[mid, dashed] (0.56,-1.22) -- (-0.75,0.56);
\draw[mid, dashed] (-1.59,-1.46) -- (1.06,0.21);
\draw[mid, dashed] (1.73,-1.04) -- (0.70,0.35);
\draw[mid, dashed] (-2.24,-0.94) -- (0.06,0.51);
\draw[mid, dashed] (2.80,-0.74) -- (2.24,0.02);
\draw[mid, dashed] (-2.88,-0.41) -- (-1.12,0.70);
\draw[mid, dashed] (3.96,-0.56) -- (3.78,-0.31);
\draw[mid, dashed] (-3.53,0.11) -- (-2.29,0.89);
\draw[->] (-1.05,-1.40) -- (-0.30,-1.24);
\node[fill=white, inner sep=1pt] at (-0.04,-1.18) {\footnotesize $x_1$};
\draw[->] (-1.05,-1.40) -- (-1.45,-1.10);
\node[fill=white, inner sep=1pt] at (-1.59,-0.99) {\footnotesize $x_2$};
\draw[very thick] (3.74,-0.26) -- (-2.29,0.89);
\pa{0.22,1.26}
\pa{0.58,1.12}
\pa{-0.05,1.07}
\pa{-0.96,1.02}
\pa{-0.49,1.01}
\pa{0.13,0.90}
\pa{0.62,0.89}
\pa{-0.28,0.79}
\pa{-0.74,0.79}
\pa{0.34,0.71}
\pb{-0.71,0.13}
\pb{0.07,0.05}
\pb{-1.41,0.04}
\pb{0.98,-0.05}
\pb{-0.67,-0.22}
\pb{-1.16,-0.28}
\pb{-0.69,-0.43}
\pb{-1.35,-0.52}
\pb{-0.05,-0.52}
\pb{-0.66,-0.66}
\draw[mid, thick] (-1.24,-4.03) -- (-4.06,-0.23);
\draw[mid, thick] (-1.24,-4.03) -- (4.06,-0.69);
\draw[mid] (-0.36,-3.47) -- (-2.33,-0.81);
\draw[mid] (-1.71,-3.39) -- (2.18,-0.94);
\draw[mid] (3.41,-0.17) -- (3.59,-0.05);
\draw[mid] (0.53,-2.91) -- (-0.51,-1.52);
\draw[mid] (-2.18,-2.76) -- (-0.06,-1.42);
\draw[mid] (2.24,0.02) -- (3.12,0.58);
\draw[mid] (1.41,-2.36) -- (0.56,-1.22);
\draw[mid] (-0.75,0.56) -- (-1.41,1.44);
\draw[mid] (-2.65,-2.13) -- (-1.59,-1.46);
\draw[mid] (1.06,0.21) -- (2.65,1.21);
\draw[mid] (2.29,-1.80) -- (1.73,-1.04);
\draw[mid] (0.70,0.35) -- (-0.53,2.00);
\draw[mid] (-3.12,-1.49) -- (-2.24,-0.94);
\draw[mid] (0.06,0.51) -- (2.18,1.85);
\draw[mid] (3.17,-1.24) -- (2.80,-0.74);
\draw[mid] (2.24,0.02) -- (0.36,2.56);
\draw[mid] (-3.59,-0.86) -- (-2.88,-0.41);
\draw[mid] (-1.12,0.70) -- (1.71,2.48);
\draw[mid, thick] (4.06,-0.69) -- (3.96,-0.56);
\draw[mid, thick] (3.78,-0.31) -- (1.24,3.11);
\draw[mid, thick] (-4.06,-0.23) -- (-3.53,0.11);
\draw[mid, thick] (-2.29,0.89) -- (1.24,3.11);
\node[anchor=south, fill=white, inner sep=1pt] at (-2.29,1.01) {\footnotesize $g(\mathbf x) = 0$};
\node[anchor=west] at (-4.6,-4.59) {The plane crosses zero along a line. This line is the decision boundary.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.92s = "true", 8.16s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.35,-1.64) -- (4.02,-0.55) -- (1.35,1.64) -- (-4.02,0.55) -- cycle;
\draw[mid, dashed] (-2.24,-0.91) -- (-3.13,0.37);
\draw[mid, dashed] (2.32,-0.86) -- (3.40,-0.20);
\draw[mid, dashed] (-0.54,-1.51) -- (-2.23,0.91);
\draw[mid, dashed] (0.09,-1.31) -- (2.24,-0.00);
\draw[mid, dashed] (0.53,-1.22) -- (-0.71,0.56);
\draw[mid, dashed] (-1.61,-1.44) -- (1.07,0.20);
\draw[mid, dashed] (1.70,-1.06) -- (0.72,0.35);
\draw[mid, dashed] (-2.24,-0.91) -- (0.09,0.51);
\draw[mid, dashed] (2.77,-0.77) -- (2.24,-0.00);
\draw[mid, dashed] (-2.86,-0.38) -- (-1.07,0.71);
\draw[mid, dashed] (3.93,-0.60) -- (3.75,-0.35);
\draw[mid, dashed] (-3.48,0.15) -- (-2.23,0.91);
\draw[->] (-1.15,-1.39) -- (-0.39,-1.24);
\node[fill=white, inner sep=1pt] at (-0.12,-1.18) {\footnotesize $x_1$};
\draw[->] (-1.15,-1.39) -- (-1.53,-1.08);
\node[fill=white, inner sep=1pt] at (-1.66,-0.97) {\footnotesize $x_2$};
\draw[very thick] (3.72,-0.31) -- (-2.23,0.91);
\pa{0.31,1.25}
\pa{0.65,1.11}
\pa{0.02,1.07}
\pa{-0.90,1.03}
\pa{-0.42,1.01}
\pa{0.19,0.90}
\pa{0.68,0.88}
\pa{-0.69,0.80}
\pa{-0.23,0.80}
\pa{0.39,0.70}
\pb{-0.70,0.14}
\pb{-1.41,0.06}
\pb{0.07,0.05}
\pb{0.97,-0.06}
\pb{-0.68,-0.21}
\pb{-1.18,-0.26}
\pb{-0.71,-0.42}
\pb{-1.39,-0.50}
\pb{-0.08,-0.52}
\pb{-0.71,-0.65}
\draw[mid, thick] (-1.35,-4.01) -- (-4.02,-0.18);
\draw[mid, thick] (-1.35,-4.01) -- (4.02,-0.73);
\draw[mid] (-0.46,-3.46) -- (-2.24,-0.91);
\draw[mid] (-1.80,-3.37) -- (2.32,-0.86);
\draw[mid] (3.40,-0.20) -- (3.58,-0.09);
\draw[mid] (0.44,-2.92) -- (-0.54,-1.51);
\draw[mid] (-2.24,-2.73) -- (0.09,-1.31);
\draw[mid] (2.24,-0.00) -- (3.13,0.54);
\draw[mid] (1.34,-2.37) -- (0.53,-1.22);
\draw[mid] (-0.71,0.56) -- (-1.34,1.46);
\draw[mid] (-2.69,-2.10) -- (-1.61,-1.44);
\draw[mid] (1.07,0.20) -- (2.69,1.18);
\draw[mid] (2.23,-1.83) -- (1.70,-1.06);
\draw[mid] (0.72,0.35) -- (-0.44,2.00);
\draw[mid] (-3.13,-1.46) -- (-2.24,-0.91);
\draw[mid] (0.09,0.51) -- (2.24,1.82);
\draw[mid] (3.13,-1.28) -- (2.77,-0.77);
\draw[mid] (2.24,-0.00) -- (0.46,2.55);
\draw[mid] (-3.58,-0.82) -- (-2.86,-0.38);
\draw[mid] (-1.07,0.71) -- (1.80,2.46);
\draw[mid, thick] (4.02,-0.73) -- (3.93,-0.60);
\draw[mid, thick] (3.75,-0.35) -- (1.35,3.10);
\draw[mid, thick] (-4.02,-0.18) -- (-3.48,0.15);
\draw[mid, thick] (-2.23,0.91) -- (1.35,3.10);
\node[anchor=south, fill=white, inner sep=1pt] at (-2.23,1.03) {\footnotesize $g(\mathbf x) = 0$};
\node[anchor=west] at (-4.6,-4.59) {The plane crosses zero along a line. This line is the decision boundary.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.16s = "true", 8.4s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.59,-1.60) -- (3.93,-0.65) -- (1.59,1.60) -- (-3.93,0.65) -- cycle;
\draw[mid, dashed] (-2.08,-1.12) -- (-3.01,0.44);
\draw[mid, dashed] (2.25,-0.91) -- (3.36,-0.29);
\draw[mid, dashed] (-0.61,-1.50) -- (-2.09,0.96);
\draw[mid, dashed] (0.02,-1.31) -- (2.23,-0.06);
\draw[mid, dashed] (0.47,-1.23) -- (-0.63,0.58);
\draw[mid, dashed] (-1.66,-1.40) -- (1.10,0.17);
\draw[mid, dashed] (1.62,-1.10) -- (0.76,0.33);
\draw[mid, dashed] (-2.23,-0.86) -- (0.16,0.51);
\draw[mid, dashed] (2.70,-0.83) -- (2.23,-0.06);
\draw[mid, dashed] (-2.81,-0.31) -- (-0.97,0.74);
\draw[mid, dashed] (3.86,-0.70) -- (3.70,-0.44);
\draw[mid, dashed] (-3.38,0.23) -- (-2.09,0.96);
\draw[->] (-1.35,-1.36) -- (-0.57,-1.22);
\node[fill=white, inner sep=1pt] at (-0.29,-1.18) {\footnotesize $x_1$};
\draw[->] (-1.35,-1.36) -- (-1.68,-1.04);
\node[fill=white, inner sep=1pt] at (-1.80,-0.93) {\footnotesize $x_2$};
\draw[very thick] (3.67,-0.40) -- (-2.09,0.96);
\pa{0.49,1.24}
\pa{0.82,1.09}
\pa{0.18,1.07}
\pa{-0.74,1.05}
\pa{-0.27,1.02}
\pa{0.32,0.89}
\pa{0.81,0.86}
\pa{-0.57,0.82}
\pa{-0.11,0.80}
\pa{0.49,0.69}
\pb{-0.68,0.16}
\pb{-1.40,0.09}
\pb{0.08,0.04}
\pb{0.96,-0.09}
\pb{-0.71,-0.19}
\pb{-1.22,-0.24}
\pb{-0.77,-0.40}
\pb{-1.46,-0.47}
\pb{-0.16,-0.52}
\pb{-0.80,-0.63}
\draw[mid, thick] (-1.59,-3.98) -- (-3.93,-0.08);
\draw[mid, thick] (-1.59,-3.98) -- (3.93,-0.83);
\draw[mid] (-0.67,-3.45) -- (-2.08,-1.12);
\draw[mid] (-1.98,-3.33) -- (2.25,-0.91);
\draw[mid] (3.36,-0.29) -- (3.54,-0.18);
\draw[mid] (0.25,-2.93) -- (-0.61,-1.50);
\draw[mid] (-2.37,-2.68) -- (0.02,-1.31);
\draw[mid] (2.23,-0.06) -- (3.15,0.47);
\draw[mid] (1.17,-2.40) -- (0.47,-1.23);
\draw[mid] (-0.63,0.58) -- (-1.17,1.49);
\draw[mid] (-2.76,-2.03) -- (-1.66,-1.40);
\draw[mid] (1.10,0.17) -- (2.76,1.12);
\draw[mid] (2.09,-1.88) -- (1.62,-1.10);
\draw[mid] (0.76,0.33) -- (-0.25,2.01);
\draw[mid] (-3.15,-1.38) -- (-2.23,-0.86);
\draw[mid] (0.16,0.51) -- (2.37,1.76);
\draw[mid] (3.01,-1.35) -- (2.70,-0.83);
\draw[mid] (2.23,-0.06) -- (0.67,2.54);
\draw[mid] (-3.54,-0.73) -- (-2.81,-0.31);
\draw[mid] (-0.97,0.74) -- (1.98,2.41);
\draw[mid, thick] (3.93,-0.83) -- (3.86,-0.70);
\draw[mid, thick] (3.70,-0.44) -- (1.59,3.06);
\draw[mid, thick] (-3.93,-0.08) -- (-3.38,0.23);
\draw[mid, thick] (-2.09,0.96) -- (1.59,3.06);
\node[anchor=south, fill=white, inner sep=1pt] at (-2.09,1.08) {\footnotesize $g(\mathbf x) = 0$};
\node[anchor=west] at (-4.6,-4.59) {The plane crosses zero along a line. This line is the decision boundary.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 8.64s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.82,-1.56) -- (3.83,-0.74) -- (1.82,1.56) -- (-3.83,0.74) -- cycle;
\draw[mid, dashed] (-1.88,-1.46) -- (-2.89,0.51);
\draw[mid, dashed] (2.18,-0.97) -- (3.31,-0.37);
\draw[mid, dashed] (-0.74,-1.35) -- (-1.95,1.01);
\draw[mid, dashed] (-0.04,-1.31) -- (2.22,-0.11);
\draw[mid, dashed] (0.40,-1.25) -- (-0.54,0.59);
\draw[mid, dashed] (-1.88,-1.46) -- (1.13,0.15);
\draw[mid, dashed] (1.54,-1.14) -- (0.81,0.31);
\draw[mid, dashed] (-2.41,-0.90) -- (0.23,0.50);
\draw[mid, dashed] (2.62,-0.90) -- (2.22,-0.11);
\draw[mid, dashed] (-2.93,-0.35) -- (-0.86,0.76);
\draw[mid, dashed] (3.76,-0.79) -- (3.63,-0.53);
\draw[mid, dashed] (-3.45,0.21) -- (-1.95,1.01);
\draw[->] (-1.55,-1.32) -- (-0.75,-1.21);
\node[fill=white, inner sep=1pt] at (-0.47,-1.17) {\footnotesize $x_1$};
\draw[->] (-1.55,-1.32) -- (-1.83,-1.00);
\node[fill=white, inner sep=1pt] at (-1.93,-0.88) {\footnotesize $x_2$};
\draw[very thick] (3.61,-0.49) -- (-1.94,1.01);
\pa{0.67,1.23}
\pa{0.98,1.07}
\pa{-0.58,1.07}
\pa{0.33,1.06}
\pa{-0.12,1.03}
\pa{0.45,0.88}
\pa{0.94,0.84}
\pa{-0.45,0.83}
\pa{0.01,0.80}
\pa{0.59,0.68}
\pb{-0.66,0.17}
\pb{-1.38,0.13}
\pb{0.08,0.04}
\pb{0.95,-0.11}
\pb{-0.74,-0.18}
\pb{-1.25,-0.21}
\pb{-0.83,-0.38}
\pb{-1.52,-0.43}
\pb{-0.24,-0.51}
\pb{-0.89,-0.61}
\draw[mid, thick] (-1.82,-3.93) -- (-3.83,0.01);
\draw[mid, thick] (-1.82,-3.93) -- (3.83,-0.92);
\draw[mid] (-0.88,-3.43) -- (-1.88,-1.46);
\draw[mid] (-2.16,-3.28) -- (2.18,-0.97);
\draw[mid] (3.31,-0.37) -- (3.50,-0.27);
\draw[mid] (0.06,-2.93) -- (-0.74,-1.35);
\draw[mid] (-2.49,-2.62) -- (-0.04,-1.31);
\draw[mid] (2.22,-0.11) -- (3.16,0.39);
\draw[mid] (1.00,-2.43) -- (0.40,-1.25);
\draw[mid] (-0.54,0.59) -- (-1.00,1.52);
\draw[mid] (-2.83,-1.96) -- (-1.88,-1.46);
\draw[mid] (1.13,0.15) -- (2.83,1.05);
\draw[mid] (1.95,-1.93) -- (1.54,-1.14);
\draw[mid] (0.81,0.31) -- (-0.06,2.02);
\draw[mid] (-3.16,-1.30) -- (-2.41,-0.90);
\draw[mid] (0.23,0.50) -- (2.49,1.71);
\draw[mid] (2.89,-1.43) -- (2.62,-0.90);
\draw[mid] (2.22,-0.11) -- (0.88,2.52);
\draw[mid] (-3.50,-0.65) -- (-2.93,-0.35);
\draw[mid] (-0.86,0.76) -- (2.16,2.36);
\draw[mid, thick] (3.83,-0.92) -- (3.76,-0.79);
\draw[mid, thick] (3.63,-0.53) -- (1.82,3.02);
\draw[mid, thick] (-3.83,0.01) -- (-3.45,0.21);
\draw[mid, thick] (-1.95,1.01) -- (1.82,3.02);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.94,1.13) {\footnotesize $g(\mathbf x) = 0$};
\node[anchor=west] at (-4.6,-4.59) {The plane crosses zero along a line. This line is the decision boundary.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.64s = "true", 11.24s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-1.93,-1.54) -- (3.78,-0.78) -- (1.93,1.54) -- (-3.78,0.78) -- cycle;
\draw[mid, dashed] (-1.84,-1.57) -- (-2.83,0.54);
\draw[mid, dashed] (2.14,-0.99) -- (3.28,-0.40);
\draw[mid, dashed] (-0.77,-1.34) -- (-1.88,1.03);
\draw[mid, dashed] (-0.07,-1.31) -- (2.21,-0.14);
\draw[mid, dashed] (0.37,-1.25) -- (-0.49,0.60);
\draw[mid, dashed] (-1.90,-1.44) -- (1.14,0.13);
\draw[mid, dashed] (1.45,-1.02) -- (0.83,0.30);
\draw[mid, dashed] (-2.40,-0.88) -- (0.26,0.50);
\draw[mid, dashed] (2.58,-0.93) -- (2.21,-0.14);
\draw[mid, dashed] (-2.90,-0.31) -- (-0.81,0.77);
\draw[mid, dashed] (3.72,-0.83) -- (3.59,-0.57);
\draw[mid, dashed] (-3.40,0.25) -- (-1.88,1.03);
\draw[->] (-1.64,-1.31) -- (-0.83,-1.20);
\node[fill=white, inner sep=1pt] at (-0.55,-1.16) {\footnotesize $x_1$};
\draw[->] (-1.64,-1.31) -- (-1.90,-0.98);
\node[fill=white, inner sep=1pt] at (-1.99,-0.86) {\footnotesize $x_2$};
\draw[very thick] (3.57,-0.53) -- (-1.87,1.03);
\pa{0.75,1.22}
\pa{-0.51,1.08}
\pa{1.05,1.06}
\pa{0.40,1.06}
\pa{-0.05,1.03}
\pa{0.51,0.88}
\pa{-0.39,0.83}
\pa{0.99,0.83}
\pa{0.06,0.80}
\pa{0.64,0.67}
\pb{-0.64,0.18}
\pb{-1.37,0.14}
\pb{0.09,0.04}
\pb{0.94,-0.12}
\pb{-0.75,-0.17}
\pb{-1.27,-0.19}
\pb{-0.86,-0.37}
\pb{-1.55,-0.41}
\pb{-0.27,-0.51}
\pb{-0.93,-0.60}
\draw (2.03,0.04) -- (2.23,-0.02) -- (2.09,-0.10);
\draw[->, very thick] (1.88,-0.04) -- (2.43,0.27);
\draw[mid, thick] (-1.93,-3.91) -- (-3.78,0.05);
\draw[mid, thick] (-1.93,-3.91) -- (3.78,-0.97);
\draw[mid] (-0.98,-3.42) -- (-1.84,-1.57);
\draw[mid] (-2.24,-3.25) -- (2.14,-0.99);
\draw[mid] (3.28,-0.40) -- (3.47,-0.31);
\draw[mid] (-0.02,-2.93) -- (-0.77,-1.34);
\draw[mid] (-2.54,-2.59) -- (-0.07,-1.31);
\draw[mid] (2.21,-0.14) -- (3.16,0.36);
\draw[mid] (0.93,-2.44) -- (0.37,-1.25);
\draw[mid] (-0.49,0.60) -- (-0.93,1.53);
\draw[mid] (-2.85,-1.93) -- (-1.90,-1.44);
\draw[mid] (1.14,0.13) -- (2.85,1.02);
\draw[mid] (1.88,-1.95) -- (1.45,-1.02);
\draw[mid] (0.83,0.30) -- (0.02,2.02);
\draw[mid] (-3.16,-1.27) -- (-2.40,-0.88);
\draw[mid] (0.26,0.50) -- (2.54,1.68);
\draw[mid] (2.83,-1.46) -- (2.58,-0.93);
\draw[mid] (2.21,-0.14) -- (0.98,2.51);
\draw[mid] (-3.47,-0.61) -- (-2.90,-0.31);
\draw[mid] (-0.81,0.77) -- (2.24,2.34);
\draw[mid, thick] (3.78,-0.97) -- (3.72,-0.83);
\draw[mid, thick] (3.59,-0.57) -- (1.93,3.00);
\draw[mid, thick] (-3.78,0.05) -- (-3.40,0.25);
\draw[mid, thick] (-1.88,1.03) -- (1.93,3.00);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.87,1.15) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.51,0.05) {$\mathbf w$};
\node[anchor=west] at (-4.6,-4.59) {The vector $\mathbf w$ is perpendicular to the boundary and points toward $g > 0$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.24s = "true", 11.48s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-2.03,-1.52) -- (3.73,-0.83) -- (2.03,1.52) -- (-3.73,0.83) -- cycle;
\draw[mid, dashed] (-1.86,-1.55) -- (-2.77,0.57);
\draw[mid, dashed] (2.10,-1.02) -- (3.25,-0.44);
\draw[mid, dashed] (-0.79,-1.34) -- (-1.81,1.06);
\draw[mid, dashed] (-0.10,-1.31) -- (2.20,-0.16);
\draw[mid, dashed] (0.34,-1.25) -- (-0.45,0.61);
\draw[mid, dashed] (-2.11,-1.51) -- (1.15,0.12);
\draw[mid, dashed] (1.41,-1.04) -- (0.85,0.29);
\draw[mid, dashed] (-2.39,-0.85) -- (0.29,0.50);
\draw[mid, dashed] (2.54,-0.96) -- (2.20,-0.16);
\draw[mid, dashed] (-2.87,-0.28) -- (-0.76,0.78);
\draw[mid, dashed] (3.67,-0.87) -- (3.56,-0.61);
\draw[mid, dashed] (-3.34,0.29) -- (-1.81,1.06);
\draw[->] (-1.72,-1.29) -- (-0.91,-1.19);
\node[fill=white, inner sep=1pt] at (-0.62,-1.16) {\footnotesize $x_1$};
\draw[->] (-1.72,-1.29) -- (-1.96,-0.96);
\node[fill=white, inner sep=1pt] at (-2.05,-0.84) {\footnotesize $x_2$};
\draw[very thick] (3.54,-0.56) -- (-1.80,1.05);
\pa{0.84,1.21}
\pa{-0.44,1.08}
\pa{0.48,1.05}
\pa{1.12,1.05}
\pa{0.02,1.03}
\pa{0.57,0.87}
\pa{-0.34,0.84}
\pa{1.05,0.82}
\pa{0.12,0.80}
\pa{0.68,0.67}
\pb{-0.63,0.19}
\pb{-1.36,0.16}
\pb{0.09,0.04}
\pb{0.93,-0.13}
\pb{-0.76,-0.16}
\pb{-1.28,-0.18}
\pb{-0.88,-0.36}
\pb{-1.58,-0.39}
\pb{-0.30,-0.50}
\pb{-0.97,-0.59}
\draw (2.03,0.02) -- (2.23,-0.04) -- (2.08,-0.12);
\draw[->, very thick] (1.88,-0.06) -- (2.45,0.25);
\draw[mid, thick] (-2.03,-3.89) -- (-3.73,0.09);
\draw[mid, thick] (-2.03,-3.89) -- (3.73,-1.01);
\draw[mid] (-1.07,-3.41) -- (-1.86,-1.55);
\draw[mid] (-2.31,-3.23) -- (2.10,-1.02);
\draw[mid] (3.25,-0.44) -- (3.44,-0.34);
\draw[mid] (-0.11,-2.93) -- (-0.79,-1.34);
\draw[mid] (-2.59,-2.56) -- (-0.10,-1.31);
\draw[mid] (2.20,-0.16) -- (3.16,0.32);
\draw[mid] (0.85,-2.45) -- (0.34,-1.25);
\draw[mid] (-0.45,0.61) -- (-0.85,1.54);
\draw[mid] (-2.88,-1.90) -- (-2.11,-1.51);
\draw[mid] (1.15,0.12) -- (2.88,0.98);
\draw[mid] (1.81,-1.97) -- (1.41,-1.04);
\draw[mid] (0.85,0.29) -- (0.11,2.02);
\draw[mid] (-3.16,-1.23) -- (-2.39,-0.85);
\draw[mid] (0.29,0.50) -- (2.59,1.65);
\draw[mid] (2.77,-1.49) -- (2.54,-0.96);
\draw[mid] (2.20,-0.16) -- (1.07,2.50);
\draw[mid] (-3.44,-0.57) -- (-2.87,-0.28);
\draw[mid] (-0.76,0.78) -- (2.31,2.31);
\draw[mid, thick] (3.73,-1.01) -- (3.67,-0.87);
\draw[mid, thick] (3.56,-0.61) -- (2.03,2.98);
\draw[mid, thick] (-3.73,0.09) -- (-3.34,0.29);
\draw[mid, thick] (-1.81,1.06) -- (2.03,2.98);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.80,1.17) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.51,0.02) {$\mathbf w$};
\node[anchor=west] at (-4.6,-4.59) {The vector $\mathbf w$ is perpendicular to the boundary and points toward $g > 0$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.48s = "true", 11.72s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-2.25,-1.46) -- (3.60,-0.91) -- (2.25,1.46) -- (-3.60,0.91) -- cycle;
\draw[mid, dashed] (-1.95,-1.37) -- (-2.62,0.64);
\draw[mid, dashed] (2.01,-1.07) -- (3.18,-0.52);
\draw[mid, dashed] (-0.84,-1.32) -- (-1.65,1.10);
\draw[mid, dashed] (0.03,-1.22) -- (2.17,-0.21);
\draw[mid, dashed] (0.27,-1.26) -- (-0.36,0.62);
\draw[mid, dashed] (-2.14,-1.46) -- (1.17,0.09);
\draw[mid, dashed] (1.33,-1.07) -- (0.88,0.27);
\draw[mid, dashed] (-2.56,-0.88) -- (0.36,0.49);
\draw[mid, dashed] (2.44,-1.02) -- (2.17,-0.21);
\draw[mid, dashed] (-2.98,-0.30) -- (-0.64,0.79);
\draw[mid, dashed] (3.55,-0.96) -- (3.46,-0.69);
\draw[mid, dashed] (-3.21,0.37) -- (-1.65,1.10);
\draw[->] (-1.91,-1.24) -- (-1.08,-1.17);
\node[fill=white, inner sep=1pt] at (-0.79,-1.14) {\footnotesize $x_1$};
\draw[->] (-1.91,-1.24) -- (-2.10,-0.91);
\node[fill=white, inner sep=1pt] at (-2.17,-0.79) {\footnotesize $x_2$};
\draw[very thick] (3.45,-0.65) -- (-1.65,1.10);
\pa{1.01,1.19}
\pa{-0.28,1.09}
\pa{0.63,1.04}
\pa{0.17,1.03}
\pa{1.27,1.02}
\pa{0.69,0.86}
\pa{-0.21,0.84}
\pa{0.24,0.80}
\pa{1.17,0.79}
\pa{0.78,0.65}
\pb{-0.60,0.20}
\pb{-1.33,0.19}
\pb{0.10,0.04}
\pb{-0.78,-0.14}
\pb{-1.30,-0.15}
\pb{0.91,-0.15}
\pb{-0.93,-0.34}
\pb{-1.63,-0.36}
\pb{-0.38,-0.50}
\pb{-1.06,-0.56}
\draw (2.03,-0.03) -- (2.22,-0.10) -- (2.06,-0.17);
\draw[->, very thick] (1.87,-0.11) -- (2.48,0.19);
\draw[mid, thick] (-2.25,-3.84) -- (-3.60,0.18);
\draw[mid, thick] (-2.25,-3.84) -- (3.60,-1.10);
\draw[mid] (-1.27,-3.38) -- (-1.95,-1.37);
\draw[mid] (-2.47,-3.17) -- (2.01,-1.07);
\draw[mid] (3.18,-0.52) -- (3.37,-0.43);
\draw[mid] (-0.30,-2.92) -- (-0.84,-1.32);
\draw[mid] (-2.70,-2.50) -- (0.03,-1.22);
\draw[mid] (2.17,-0.21) -- (3.15,0.24);
\draw[mid] (0.67,-2.47) -- (0.27,-1.26);
\draw[mid] (-0.36,0.62) -- (-0.67,1.55);
\draw[mid] (-2.92,-1.83) -- (-2.14,-1.46);
\draw[mid] (1.17,0.09) -- (2.92,0.91);
\draw[mid] (1.65,-2.01) -- (1.33,-1.07);
\draw[mid] (0.88,0.27) -- (0.30,2.01);
\draw[mid] (-3.15,-1.16) -- (-2.56,-0.88);
\draw[mid] (0.36,0.49) -- (2.70,1.58);
\draw[mid] (2.62,-1.55) -- (2.44,-1.02);
\draw[mid] (2.17,-0.21) -- (1.27,2.47);
\draw[mid] (-3.37,-0.49) -- (-2.98,-0.30);
\draw[mid] (-0.64,0.79) -- (2.47,2.25);
\draw[mid, thick] (3.60,-1.10) -- (3.55,-0.96);
\draw[mid, thick] (3.46,-0.69) -- (2.25,2.93);
\draw[mid, thick] (-3.60,0.18) -- (-3.21,0.37);
\draw[mid, thick] (-1.65,1.10) -- (2.25,2.93);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.65,1.22) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.51,-0.04) {$\mathbf w$};
\node[anchor=west] at (-4.6,-4.59) {The vector $\mathbf w$ is perpendicular to the boundary and points toward $g > 0$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.72s = "true", 11.96s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-2.46,-1.41) -- (3.46,-1.00) -- (2.46,1.41) -- (-3.46,1.00) -- cycle;
\draw[mid, dashed] (-1.97,-1.32) -- (-2.47,0.70);
\draw[mid, dashed] (1.91,-1.11) -- (3.09,-0.59);
\draw[mid, dashed] (-0.89,-1.29) -- (-1.48,1.14);
\draw[mid, dashed] (-0.03,-1.22) -- (2.14,-0.27);
\draw[mid, dashed] (0.20,-1.27) -- (-0.27,0.62);
\draw[mid, dashed] (-2.17,-1.41) -- (1.18,0.06);
\draw[mid, dashed] (1.25,-1.10) -- (0.92,0.25);
\draw[mid, dashed] (-2.73,-0.91) -- (0.43,0.48);
\draw[mid, dashed] (2.34,-1.08) -- (2.14,-0.27);
\draw[mid, dashed] (-2.90,-0.23) -- (-0.53,0.81);
\draw[mid, dashed] (3.42,-1.05) -- (3.36,-0.78);
\draw[mid, dashed] (-3.26,0.36) -- (-1.48,1.14);
\draw[->] (-2.09,-1.20) -- (-1.25,-1.14);
\node[fill=white, inner sep=1pt] at (-0.96,-1.12) {\footnotesize $x_1$};
\draw[->] (-2.09,-1.20) -- (-2.23,-0.85);
\node[fill=white, inner sep=1pt] at (-2.28,-0.73) {\footnotesize $x_2$};
\draw[very thick] (3.34,-0.73) -- (-1.48,1.13);
\pa{1.19,1.16}
\pa{-0.12,1.09}
\pa{0.78,1.02}
\pa{0.32,1.02}
\pa{1.42,0.99}
\pa{-0.09,0.85}
\pa{0.82,0.84}
\pa{0.35,0.79}
\pa{1.28,0.76}
\pa{0.87,0.63}
\pb{-1.30,0.22}
\pb{-0.57,0.22}
\pb{0.10,0.04}
\pb{-1.32,-0.11}
\pb{-0.80,-0.12}
\pb{0.88,-0.18}
\pb{-1.68,-0.31}
\pb{-0.98,-0.32}
\pb{-0.45,-0.49}
\pb{-1.14,-0.54}
\draw (2.02,-0.08) -- (2.20,-0.15) -- (2.03,-0.22);
\draw[->, very thick] (1.85,-0.15) -- (2.50,0.13);
\draw[mid, thick] (-2.46,-3.78) -- (-3.46,0.27);
\draw[mid, thick] (-2.46,-3.78) -- (3.46,-1.18);
\draw[mid] (-1.47,-3.35) -- (-1.97,-1.32);
\draw[mid] (-2.63,-3.11) -- (1.91,-1.11);
\draw[mid] (3.09,-0.59) -- (3.29,-0.51);
\draw[mid] (-0.49,-2.92) -- (-0.89,-1.29);
\draw[mid] (-2.79,-2.43) -- (-0.03,-1.22);
\draw[mid] (2.14,-0.27) -- (3.12,0.17);
\draw[mid] (0.50,-2.48) -- (0.20,-1.27);
\draw[mid] (-0.27,0.62) -- (-0.50,1.57);
\draw[mid] (-2.96,-1.76) -- (-2.17,-1.41);
\draw[mid] (1.18,0.06) -- (2.96,0.84);
\draw[mid] (1.48,-2.05) -- (1.25,-1.10);
\draw[mid] (0.92,0.25) -- (0.49,2.00);
\draw[mid] (-3.12,-1.08) -- (-2.73,-0.91);
\draw[mid] (0.43,0.48) -- (2.79,1.52);
\draw[mid] (2.47,-1.62) -- (2.34,-1.08);
\draw[mid] (2.14,-0.27) -- (1.47,2.43);
\draw[mid] (-3.29,-0.41) -- (-2.90,-0.23);
\draw[mid] (-0.53,0.81) -- (2.63,2.19);
\draw[mid, thick] (3.46,-1.18) -- (3.42,-1.05);
\draw[mid, thick] (3.36,-0.78) -- (2.46,2.87);
\draw[mid, thick] (-3.46,0.27) -- (-3.26,0.36);
\draw[mid, thick] (-1.48,1.14) -- (2.46,2.87);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.48,1.25) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.50,-0.10) {$\mathbf w$};
\node[anchor=west] at (-4.6,-4.59) {The vector $\mathbf w$ is perpendicular to the boundary and points toward $g > 0$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.96s = "true", 14.56s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-2.55,-1.38) -- (3.39,-1.04) -- (2.55,1.38) -- (-3.39,1.04) -- cycle;
\draw[mid, dashed] (-1.98,-1.30) -- (-2.40,0.73);
\draw[mid, dashed] (1.86,-1.14) -- (3.05,-0.63);
\draw[mid, dashed] (-0.91,-1.28) -- (-1.41,1.15);
\draw[mid, dashed] (-0.06,-1.22) -- (2.12,-0.29);
\draw[mid, dashed] (0.17,-1.27) -- (-0.22,0.63);
\draw[mid, dashed] (-2.18,-1.39) -- (1.19,0.05);
\draw[mid, dashed] (1.21,-1.12) -- (0.93,0.24);
\draw[mid, dashed] (-2.71,-0.88) -- (0.45,0.47);
\draw[mid, dashed] (2.29,-1.10) -- (2.12,-0.29);
\draw[mid, dashed] (-2.85,-0.20) -- (-0.48,0.81);
\draw[mid, dashed] (3.36,-1.09) -- (3.30,-0.82);
\draw[mid, dashed] (-3.19,0.39) -- (-1.41,1.15);
\draw[->] (-2.17,-1.17) -- (-1.33,-1.12);
\node[fill=white, inner sep=1pt] at (-1.03,-1.11) {\footnotesize $x_1$};
\draw[->] (-2.17,-1.17) -- (-2.29,-0.83);
\node[fill=white, inner sep=1pt] at (-2.33,-0.71) {\footnotesize $x_2$};
\draw[very thick] (3.29,-0.77) -- (-1.40,1.15);
\pa{1.26,1.15}
\pa{-0.05,1.10}
\pa{0.39,1.02}
\pa{0.85,1.01}
\pa{1.49,0.97}
\pa{-0.03,0.85}
\pa{0.87,0.83}
\pa{0.41,0.79}
\pa{1.33,0.74}
\pa{0.91,0.62}
\pb{-1.29,0.24}
\pb{-0.56,0.22}
\pb{0.10,0.03}
\pb{-1.33,-0.10}
\pb{-0.81,-0.11}
\pb{0.87,-0.19}
\pb{-1.70,-0.30}
\pb{-1.00,-0.30}
\pb{-0.48,-0.48}
\pb{-1.18,-0.52}
\draw (2.01,-0.10) -- (2.19,-0.17) -- (2.01,-0.25);
\draw[->, very thick] (1.84,-0.17) -- (2.51,0.10);
\filldraw[draw=black, fill=white, thick] (2.35,0.79) ++(-0.1,-0.1) rectangle ++(0.2,0.2);
\draw[mid, thick] (-2.55,-3.75) -- (-3.39,0.31);
\draw[mid, thick] (-2.55,-3.75) -- (3.39,-1.22);
\draw[mid] (-1.56,-3.33) -- (-1.98,-1.30);
\draw[mid] (-2.69,-3.08) -- (1.86,-1.14);
\draw[mid] (3.05,-0.63) -- (3.25,-0.54);
\draw[mid] (-0.57,-2.91) -- (-0.91,-1.28);
\draw[mid] (-2.83,-2.40) -- (-0.06,-1.22);
\draw[mid] (2.12,-0.29) -- (3.11,0.13);
\draw[mid] (0.42,-2.49) -- (0.17,-1.27);
\draw[mid] (-0.22,0.63) -- (-0.42,1.57);
\draw[mid] (-2.97,-1.72) -- (-2.18,-1.39);
\draw[mid] (1.19,0.05) -- (2.97,0.81);
\draw[mid] (1.41,-2.07) -- (1.21,-1.12);
\draw[mid] (0.93,0.24) -- (0.57,2.00);
\draw[mid] (-3.11,-1.05) -- (-2.71,-0.88);
\draw[mid] (0.45,0.47) -- (2.83,1.49);
\draw[mid] (2.40,-1.64) -- (2.29,-1.10);
\draw[mid] (2.12,-0.29) -- (1.56,2.42);
\draw[mid] (-3.25,-0.37) -- (-2.85,-0.20);
\draw[mid] (-0.48,0.81) -- (2.69,2.16);
\draw[mid, thick] (3.39,-1.22) -- (3.36,-1.09);
\draw[mid, thick] (3.30,-0.82) -- (2.55,2.84);
\draw[mid, thick] (-3.39,0.31) -- (-3.19,0.39);
\draw[mid, thick] (-1.41,1.15) -- (2.55,2.84);
\draw[very thick] (2.35,0.79) -- (2.35,1.72);
\fill (2.35,1.72) circle (2.2pt);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.40,1.27) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.50,-0.13) {$\mathbf w$};
\node[anchor=north, fill=white, inner sep=1pt] at (2.35,0.67) {$\mathbf x$};
\node[anchor=south, fill=white, inner sep=1pt] at (2.35,1.84) {\footnotesize $g(\mathbf x) = 1.02$};
\node[anchor=west] at (-4.6,-4.59) {A test point $\mathbf x$ gets the score $g(\mathbf x) = 1.02$, the height of the plane above it.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\node[anchor=west] at (4.73,1.1) {test point $\mathbf x = (2.60, 1.60)$};
\node[anchor=west] at (4.73,0.5) {\footnotesize $g(\mathbf x) = 0.40\cdot 2.60 + 0.30\cdot 1.60 - 0.50 = 1.02$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 14.56s = "true", 14.8s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-2.64,-1.35) -- (3.32,-1.08) -- (2.64,1.35) -- (-3.32,1.08) -- cycle;
\draw[mid, dashed] (-1.99,-1.28) -- (-2.32,0.76);
\draw[mid, dashed] (1.81,-1.16) -- (3.01,-0.66);
\draw[mid, dashed] (-0.93,-1.27) -- (-1.33,1.17);
\draw[mid, dashed] (-0.09,-1.22) -- (2.10,-0.31);
\draw[mid, dashed] (0.13,-1.27) -- (-0.18,0.63);
\draw[mid, dashed] (-2.19,-1.36) -- (1.19,0.04);
\draw[mid, dashed] (1.17,-1.13) -- (0.95,0.23);
\draw[mid, dashed] (-2.70,-0.85) -- (0.48,0.47);
\draw[mid, dashed] (2.23,-1.13) -- (2.10,-0.31);
\draw[mid, dashed] (-3.01,-0.25) -- (-0.42,0.82);
\draw[mid, dashed] (3.30,-1.12) -- (3.25,-0.85);
\draw[mid, dashed] (-3.12,0.43) -- (-1.33,1.17);
\draw[->] (-2.25,-1.15) -- (-1.40,-1.11);
\node[fill=white, inner sep=1pt] at (-1.11,-1.09) {\footnotesize $x_1$};
\draw[->] (-2.25,-1.15) -- (-2.34,-0.80);
\node[fill=white, inner sep=1pt] at (-2.38,-0.68) {\footnotesize $x_2$};
\draw[very thick] (3.24,-0.81) -- (-1.33,1.17);
\pa{1.34,1.14}
\pa{0.03,1.10}
\pa{0.45,1.01}
\pa{0.92,1.00}
\pa{1.55,0.95}
\pa{0.02,0.85}
\pa{0.93,0.82}
\pa{0.46,0.78}
\pa{1.38,0.73}
\pa{0.96,0.61}
\pb{-1.27,0.25}
\pb{-0.54,0.23}
\pb{0.11,0.03}
\pb{-1.33,-0.08}
\pb{-0.82,-0.10}
\pb{0.86,-0.20}
\pb{-1.72,-0.28}
\pb{-1.02,-0.29}
\pb{-0.51,-0.48}
\pb{-1.21,-0.51}
\draw (2.01,-0.12) -- (2.18,-0.20) -- (2.00,-0.27);
\draw[->, very thick] (1.83,-0.19) -- (2.52,0.07);
\filldraw[draw=black, fill=white, thick] (2.40,0.77) ++(-0.1,-0.1) rectangle ++(0.2,0.2);
\draw[{Bar[width=2mm]}-{Bar[width=2mm]}, very thick] (2.40,0.77) -- (0.92,0.20);
\draw[mid, thick] (-2.64,-3.72) -- (-3.32,0.34);
\draw[mid, thick] (-2.64,-3.72) -- (3.32,-1.26);
\draw[mid] (-1.65,-3.31) -- (-1.99,-1.28);
\draw[mid] (-2.76,-3.05) -- (1.81,-1.16);
\draw[mid] (3.01,-0.66) -- (3.21,-0.58);
\draw[mid] (-0.66,-2.90) -- (-0.93,-1.27);
\draw[mid] (-2.87,-2.37) -- (-0.09,-1.22);
\draw[mid] (2.10,-0.31) -- (3.09,0.10);
\draw[mid] (0.34,-2.49) -- (0.13,-1.27);
\draw[mid] (-0.18,0.63) -- (-0.34,1.58);
\draw[mid] (-2.98,-1.69) -- (-2.19,-1.36);
\draw[mid] (1.19,0.04) -- (2.98,0.78);
\draw[mid] (1.33,-2.08) -- (1.17,-1.13);
\draw[mid] (0.95,0.23) -- (0.66,1.99);
\draw[mid] (-3.09,-1.01) -- (-2.70,-0.85);
\draw[mid] (0.48,0.47) -- (2.87,1.45);
\draw[mid] (2.32,-1.67) -- (2.23,-1.13);
\draw[mid] (2.10,-0.31) -- (1.65,2.40);
\draw[mid] (-3.21,-0.33) -- (-3.01,-0.25);
\draw[mid] (-0.42,0.82) -- (2.76,2.13);
\draw[mid, thick] (3.32,-1.26) -- (3.30,-1.12);
\draw[mid, thick] (3.25,-0.85) -- (2.64,2.81);
\draw[mid, thick] (-3.32,0.34) -- (-3.12,0.43);
\draw[mid, thick] (-1.33,1.17) -- (2.64,2.81);
\draw[very thick] (2.40,0.77) -- (2.40,1.70);
\fill (2.40,1.70) circle (2.2pt);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.33,1.29) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.49,-0.15) {$\mathbf w$};
\node[anchor=north, fill=white, inner sep=1pt] at (2.40,0.65) {$\mathbf x$};
\node[fill=white, inner sep=1pt] at (1.87,0.39) {\footnotesize $2.04$};
\node[anchor=south, fill=white, inner sep=1pt] at (2.40,1.82) {\footnotesize $g(\mathbf x) = 1.02$};
\node[anchor=west] at (-4.6,-4.59) {Its distance to the boundary is $g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\node[anchor=west] at (4.73,1.1) {test point $\mathbf x = (2.60, 1.60)$};
\node[anchor=west] at (4.73,0.5) {\footnotesize $g(\mathbf x) = 0.40\cdot 2.60 + 0.30\cdot 1.60 - 0.50 = 1.02$};
\node[anchor=west] at (4.73,-0.1) {\footnotesize distance $= g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 14.8s = "true", 15.04s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-2.84,-1.28) -- (3.15,-1.15) -- (2.84,1.28) -- (-3.15,1.15) -- cycle;
\draw[mid, dashed] (-2.00,-1.23) -- (-2.15,0.81);
\draw[mid, dashed] (1.70,-1.20) -- (2.90,-0.73);
\draw[mid, dashed] (-0.97,-1.25) -- (-1.16,1.20);
\draw[mid, dashed] (-0.15,-1.21) -- (2.05,-0.36);
\draw[mid, dashed] (0.06,-1.27) -- (-0.08,0.63);
\draw[mid, dashed] (-2.00,-1.23) -- (1.20,0.01);
\draw[mid, dashed] (1.08,-1.16) -- (0.98,0.20);
\draw[mid, dashed] (-2.85,-0.86) -- (0.55,0.46);
\draw[mid, dashed] (2.11,-1.18) -- (2.05,-0.36);
\draw[mid, dashed] (-2.90,-0.18) -- (-0.30,0.83);
\draw[mid, dashed] (3.14,-1.20) -- (3.12,-0.93);
\draw[mid, dashed] (-3.15,0.42) -- (-1.16,1.20);
\draw[->] (-2.41,-1.09) -- (-1.56,-1.07);
\node[fill=white, inner sep=1pt] at (-1.27,-1.07) {\footnotesize $x_1$};
\draw[->] (-2.41,-1.09) -- (-2.46,-0.74);
\node[fill=white, inner sep=1pt] at (-2.47,-0.62) {\footnotesize $x_2$};
\draw[very thick] (3.12,-0.88) -- (-1.15,1.20);
\pa{1.51,1.10}
\pa{0.19,1.09}
\pa{0.60,1.00}
\pa{1.06,0.98}
\pa{1.69,0.91}
\pa{0.15,0.85}
\pa{1.05,0.79}
\pa{0.57,0.77}
\pa{1.49,0.69}
\pa{1.04,0.58}
\pb{-1.23,0.28}
\pb{-0.51,0.24}
\pb{0.11,0.03}
\pb{-1.34,-0.05}
\pb{-0.83,-0.08}
\pb{0.83,-0.22}
\pb{-1.76,-0.23}
\pb{-1.06,-0.27}
\pb{-0.58,-0.46}
\pb{-1.28,-0.48}
\draw (1.99,-0.17) -- (2.15,-0.25) -- (1.95,-0.32);
\draw[->, very thick] (1.79,-0.24) -- (2.52,0.01);
\filldraw[draw=black, fill=white, thick] (2.51,0.71) ++(-0.1,-0.1) rectangle ++(0.2,0.2);
\draw[{Bar[width=2mm]}-{Bar[width=2mm]}, very thick] (2.51,0.71) -- (0.95,0.17);
\draw[mid, thick] (-2.84,-3.66) -- (-3.15,0.42);
\draw[mid, thick] (-2.84,-3.66) -- (3.15,-1.34);
\draw[mid] (-1.84,-3.27) -- (-2.00,-1.23);
\draw[mid] (-2.89,-2.98) -- (1.70,-1.20);
\draw[mid] (2.90,-0.73) -- (3.10,-0.66);
\draw[mid] (-0.84,-2.88) -- (-0.97,-1.25);
\draw[mid] (-2.94,-2.30) -- (-0.15,-1.21);
\draw[mid] (2.05,-0.36) -- (3.05,0.02);
\draw[mid] (0.16,-2.50) -- (0.06,-1.27);
\draw[mid] (-0.08,0.63) -- (-0.16,1.58);
\draw[mid] (-3.00,-1.62) -- (-2.00,-1.23);
\draw[mid] (1.20,0.01) -- (3.00,0.70);
\draw[mid] (1.16,-2.11) -- (1.08,-1.16);
\draw[mid] (0.98,0.20) -- (0.84,1.97);
\draw[mid] (-3.05,-0.94) -- (-2.85,-0.86);
\draw[mid] (0.55,0.46) -- (2.94,1.38);
\draw[mid] (2.15,-1.72) -- (2.11,-1.18);
\draw[mid] (2.05,-0.36) -- (1.84,2.36);
\draw[mid] (-3.10,-0.26) -- (-2.90,-0.18);
\draw[mid] (-0.30,0.83) -- (2.89,2.06);
\draw[mid, thick] (3.15,-1.34) -- (3.14,-1.20);
\draw[mid, thick] (3.12,-0.93) -- (2.84,2.74);
\draw[mid, thick] (-1.16,1.20) -- (2.84,2.74);
\draw[very thick] (2.51,0.71) -- (2.51,1.64);
\fill (2.51,1.64) circle (2.2pt);
\node[anchor=south, fill=white, inner sep=1pt] at (-1.15,1.32) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.46,-0.21) {$\mathbf w$};
\node[anchor=north, fill=white, inner sep=1pt] at (2.51,0.59) {$\mathbf x$};
\node[fill=white, inner sep=1pt] at (1.92,0.35) {\footnotesize $2.04$};
\node[anchor=south, fill=white, inner sep=1pt] at (2.51,1.76) {\footnotesize $g(\mathbf x) = 1.02$};
\node[anchor=west] at (-4.6,-4.59) {Its distance to the boundary is $g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\node[anchor=west] at (4.73,1.1) {test point $\mathbf x = (2.60, 1.60)$};
\node[anchor=west] at (4.73,0.5) {\footnotesize $g(\mathbf x) = 0.40\cdot 2.60 + 0.30\cdot 1.60 - 0.50 = 1.02$};
\node[anchor=west] at (4.73,-0.1) {\footnotesize distance $= g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 15.04s = "true", 15.28s = "false", 18.68s = "false", repeats}}}]
\filldraw[draw=black, fill=white] (-3.02,-1.21) -- (2.98,-1.23) -- (3.02,1.21) -- (-2.98,1.23) -- cycle;
\draw[mid, dashed] (-3.00,-1.27) -- (-2.98,0.50);
\draw[mid, dashed] (-2.00,-1.18) -- (-1.98,0.86);
\draw[mid, dashed] (1.58,-1.24) -- (2.78,-0.80);
\draw[mid, dashed] (-1.00,-1.23) -- (-0.98,1.22);
\draw[mid, dashed] (-0.21,-1.21) -- (1.99,-0.41);
\draw[mid, dashed] (-0.01,-1.27) -- (0.01,0.63);
\draw[mid, dashed] (-2.00,-1.18) -- (1.20,-0.02);
\draw[mid, dashed] (0.99,-1.18) -- (1.00,0.18);
\draw[mid, dashed] (-2.99,-0.86) -- (0.61,0.44);
\draw[mid, dashed] (1.98,-1.23) -- (1.99,-0.41);
\draw[mid, dashed] (-2.98,-0.18) -- (-0.18,0.83);
\draw[mid, dashed] (-2.98,0.50) -- (-0.98,1.22);
\draw[->] (-2.57,-1.03) -- (-1.72,-1.03);
\node[fill=white, inner sep=1pt] at (-1.42,-1.03) {\footnotesize $x_1$};
\draw[->] (-2.57,-1.03) -- (-2.56,-0.68);
\node[fill=white, inner sep=1pt] at (-2.56,-0.56) {\footnotesize $x_2$};
\draw[very thick] (2.98,-0.96) -- (-0.97,1.22);
\pa{0.35,1.09}
\pa{1.67,1.06}
\pa{0.75,0.98}
\pa{1.21,0.95}
\pa{1.82,0.87}
\pa{0.27,0.84}
\pa{1.16,0.77}
\pa{0.68,0.75}
\pa{1.59,0.66}
\pa{1.13,0.56}
\pb{-1.19,0.31}
\pb{-0.47,0.25}
\pb{0.11,0.03}
\pb{-1.35,-0.02}
\pb{-0.84,-0.06}
\pb{-1.79,-0.19}
\pb{0.80,-0.24}
\pb{-1.10,-0.24}
\pb{-0.65,-0.45}
\pb{-1.35,-0.45}
\draw (1.96,-0.22) -- (2.10,-0.30) -- (1.90,-0.36);
\draw[->, very thick] (1.75,-0.28) -- (2.52,-0.05);
\filldraw[draw=black, fill=white, thick] (2.61,0.64) ++(-0.1,-0.1) rectangle ++(0.2,0.2);
\draw[{Bar[width=2mm]}-{Bar[width=2mm]}, very thick] (2.61,0.64) -- (0.97,0.15);
\draw[mid, thick] (-3.02,-3.59) -- (-3.00,-1.27);
\draw[mid, thick] (-3.02,-3.59) -- (2.98,-1.41);
\draw[mid] (-2.02,-3.22) -- (-2.00,-1.18);
\draw[mid] (-3.02,-2.91) -- (1.58,-1.24);
\draw[mid] (2.78,-0.80) -- (2.98,-0.73);
\draw[mid] (-1.02,-2.86) -- (-1.00,-1.23);
\draw[mid] (-3.01,-2.22) -- (-0.21,-1.21);
\draw[mid] (1.99,-0.41) -- (2.99,-0.05);
\draw[mid] (-0.02,-2.50) -- (-0.01,-1.27);
\draw[mid] (0.01,0.63) -- (0.02,1.59);
\draw[mid] (-3.00,-1.54) -- (-2.00,-1.18);
\draw[mid] (1.20,-0.02) -- (3.00,0.63);
\draw[mid] (0.98,-2.14) -- (0.99,-1.18);
\draw[mid] (1.00,0.18) -- (1.02,1.95);
\draw[mid] (0.61,0.44) -- (3.01,1.31);
\draw[mid] (1.98,-1.77) -- (1.98,-1.23);
\draw[mid] (1.99,-0.41) -- (2.02,2.31);
\draw[mid] (-0.18,0.83) -- (3.02,1.99);
\draw[mid, thick] (2.98,-1.41) -- (3.02,2.67);
\draw[mid, thick] (-0.98,1.22) -- (3.02,2.67);
\draw[very thick] (2.61,0.64) -- (2.61,1.57);
\fill (2.61,1.57) circle (2.2pt);
\node[anchor=south, fill=white, inner sep=1pt] at (-0.97,1.34) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.42,-0.27) {$\mathbf w$};
\node[anchor=north, fill=white, inner sep=1pt] at (2.61,0.52) {$\mathbf x$};
\node[fill=white, inner sep=1pt] at (1.97,0.30) {\footnotesize $2.04$};
\node[anchor=south, fill=white, inner sep=1pt] at (2.61,1.69) {\footnotesize $g(\mathbf x) = 1.02$};
\node[anchor=west] at (-4.6,-4.59) {Its distance to the boundary is $g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\node[anchor=west] at (4.73,1.1) {test point $\mathbf x = (2.60, 1.60)$};
\node[anchor=west] at (4.73,0.5) {\footnotesize $g(\mathbf x) = 0.40\cdot 2.60 + 0.30\cdot 1.60 - 0.50 = 1.02$};
\node[anchor=west] at (4.73,-0.1) {\footnotesize distance $= g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 15.28s = "true", 18.68s = "true", repeats}}}]
\filldraw[draw=black, fill=white] (-3.10,-1.18) -- (2.89,-1.26) -- (3.10,1.18) -- (-2.89,1.26) -- cycle;
\draw[mid, dashed] (-2.98,-1.24) -- (-2.89,0.53);
\draw[mid, dashed] (-2.00,-1.16) -- (-1.89,0.88);
\draw[mid, dashed] (1.53,-1.26) -- (2.73,-0.83);
\draw[mid, dashed] (-1.02,-1.22) -- (-0.89,1.23);
\draw[mid, dashed] (-0.23,-1.21) -- (1.96,-0.43);
\draw[mid, dashed] (-0.04,-1.27) -- (0.06,0.63);
\draw[mid, dashed] (-2.00,-1.16) -- (1.20,-0.04);
\draw[mid, dashed] (0.94,-1.19) -- (1.01,0.17);
\draw[mid, dashed] (-2.96,-0.83) -- (0.63,0.43);
\draw[mid, dashed] (1.92,-1.25) -- (1.96,-0.43);
\draw[mid, dashed] (-2.93,-0.15) -- (-0.13,0.83);
\draw[mid, dashed] (-2.89,0.53) -- (-0.89,1.23);
\draw[->] (-2.64,-1.00) -- (-1.79,-1.01);
\node[fill=white, inner sep=1pt] at (-1.49,-1.02) {\footnotesize $x_1$};
\draw[->] (-2.64,-1.00) -- (-2.61,-0.65);
\node[fill=white, inner sep=1pt] at (-2.60,-0.53) {\footnotesize $x_2$};
\draw[very thick] (2.92,-0.99) -- (-0.89,1.23);
\pa{0.42,1.08}
\pa{1.74,1.04}
\pa{0.81,0.97}
\pa{1.27,0.94}
\pa{1.88,0.85}
\pa{0.33,0.84}
\pa{1.21,0.75}
\pa{0.73,0.74}
\pa{1.63,0.64}
\pa{1.16,0.54}
\pb{-1.17,0.32}
\pb{-0.45,0.26}
\pb{0.12,0.03}
\pb{-1.35,-0.00}
\pb{-0.85,-0.05}
\pb{-1.80,-0.17}
\pb{-1.12,-0.23}
\pb{0.78,-0.25}
\pb{-1.38,-0.43}
\pb{-0.68,-0.44}
\draw (1.94,-0.24) -- (2.08,-0.33) -- (1.88,-0.38);
\draw[->, very thick] (1.74,-0.30) -- (2.51,-0.08);
\filldraw[draw=black, fill=white, thick] (2.65,0.61) ++(-0.1,-0.1) rectangle ++(0.2,0.2);
\draw[{Bar[width=2mm]}-{Bar[width=2mm]}, very thick] (2.65,0.61) -- (0.98,0.14);
\draw[mid, thick] (-3.10,-3.55) -- (-2.98,-1.24);
\draw[mid, thick] (-3.10,-3.55) -- (2.89,-1.44);
\draw[mid] (-2.10,-3.20) -- (-2.00,-1.16);
\draw[mid] (-3.07,-2.87) -- (1.53,-1.26);
\draw[mid] (2.73,-0.83) -- (2.93,-0.76);
\draw[mid] (-1.10,-2.85) -- (-1.02,-1.22);
\draw[mid] (-3.03,-2.19) -- (-0.23,-1.21);
\draw[mid] (1.96,-0.43) -- (2.96,-0.08);
\draw[mid] (-0.10,-2.50) -- (-0.04,-1.27);
\draw[mid] (0.06,0.63) -- (0.10,1.58);
\draw[mid] (-3.00,-1.51) -- (-2.00,-1.16);
\draw[mid] (1.20,-0.04) -- (3.00,0.60);
\draw[mid] (0.89,-2.15) -- (0.94,-1.19);
\draw[mid] (1.01,0.17) -- (1.10,1.94);
\draw[mid] (0.63,0.43) -- (3.03,1.28);
\draw[mid] (1.89,-1.80) -- (1.92,-1.25);
\draw[mid] (1.96,-0.43) -- (2.10,2.29);
\draw[mid] (-0.13,0.83) -- (3.07,1.96);
\draw[mid, thick] (2.89,-1.44) -- (3.10,2.64);
\draw[mid, thick] (-0.89,1.23) -- (3.10,2.64);
\draw[very thick] (2.65,0.61) -- (2.65,1.55);
\fill (2.65,1.55) circle (2.2pt);
\node[anchor=south, fill=white, inner sep=1pt] at (-0.89,1.35) {\footnotesize $g(\mathbf x) = 0$};
\node[fill=white, inner sep=1pt] at (2.40,-0.30) {$\mathbf w$};
\node[anchor=north, fill=white, inner sep=1pt] at (2.65,0.49) {$\mathbf x$};
\node[fill=white, inner sep=1pt] at (1.99,0.28) {\footnotesize $2.04$};
\node[anchor=south, fill=white, inner sep=1pt] at (2.65,1.67) {\footnotesize $g(\mathbf x) = 1.02$};
\node[anchor=west] at (-4.6,-4.59) {Its distance to the boundary is $g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$.};
\node[anchor=west] at (4.73,3.2) {$g(\mathbf x) = \mathbf w^T\mathbf x + b$};
\node[anchor=west] at (4.73,2.6) {$\mathbf w = (0.40, 0.30)$, \ $b = -0.50$};
\node[anchor=west] at (4.73,2.0) {$\|\mathbf w\| = 0.50$};
\node[anchor=west] at (4.73,1.1) {test point $\mathbf x = (2.60, 1.60)$};
\node[anchor=west] at (4.73,0.5) {\footnotesize $g(\mathbf x) = 0.40\cdot 2.60 + 0.30\cdot 1.60 - 0.50 = 1.02$};
\node[anchor=west] at (4.73,-0.1) {\footnotesize distance $= g(\mathbf x)/\|\mathbf w\| = 1.02/0.50 = 2.04$};
\end{scope}
\end{tikzpicture}
\end{document}

Properties

(Convex Regions) The argmax rule cannot capture a class whose points form two separate clusters.

Take two points in region and any point between them, with . Linearity gives , and the same holds for every . Since at both endpoints, , so is in too. Each region is therefore one convex piece, with none of the gaps of one-vs-rest. It also means no linear discriminant can solve XOR-type data, where one class occupies two opposite corners. Nonlinear features or a nonlinear model are then needed, as in kernel SVMs or neural networks.

(Nearest Mean in Mahalanobis Distance) LDA assigns each input to the closest class mean, measured in the metric of the shared covariance.

Adding the term , which is the same for every class, turns into . The quadratic form is the squared Mahalanobis distance, a distance that counts steps in units of the class spread. With and equal priors, LDA reduces to nearest-centroid classification in ordinary distance. The Mahalanobis distance between the two means, , sets the difficulty. With equal priors the Bayes error is , where is the standard normal CDF.

(LDA Versus Logistic Regression) LDA and logistic regression produce the same linear log-odds but estimate them differently.

LDA fits the joint distribution of and by Gaussian maximum likelihood. Logistic regression fits only the conditional distribution of given . When the classes are Gaussian, LDA uses that extra information and has lower variance. Efron (1975) measured the cost of ignoring that information, as quoted in ESL (sec. 4.4.5). In the worst case, logistic regression loses about 30% efficiency in error rate, asymptotically. LDA estimates its means and covariance from every point, including points far from the boundary. Outliers and heavy-tailed classes therefore pull LDA’s boundary, while logistic regression mostly ignores well-classified points. LDA also has a closed form and stays finite on separable data, where unregularized logistic regression diverges.

(QDA Needs More Data) QDA estimates covariance matrices instead of one, which multiplies its covariance parameters by .

A covariance has free entries. With and , LDA estimates covariance entries and QDA estimates . When a class has points, its sample covariance is singular, and QDA cannot invert it. Regularized discriminant analysis (Friedman 1989; ESL sec. 4.3.1) blends the two models with . Cross-validation chooses . The blend trades QDA’s flexibility against LDA’s lower variance, as described in 2.3.1. Bias-Variance Decomposition.

(At Most Directions) With classes, Fisher’s criterion yields at most useful projection directions.

The multi-class version replaces the squared mean difference with the between-class scatter , where is the overall mean. The centered means sum to zero after weighting, so has rank at most . The useful directions are the top eigenvectors of . Ten digit classes thus give at most nine directions, whatever the number of pixels. Projecting onto them is called reduced-rank LDA. It is a supervised alternative to PCA, which ignores the labels.

Derivation

We want to show that Gaussian classes with a shared covariance give linear log-odds. The Gaussian density of class is proportional to , and the normalizing constant is the same for both classes. Bayes’ rule gives the log-odds

Expanding both quadratic forms, the terms cancel. The cross terms give , using the symmetry of . The rest are constants, which form . So the log-odds equal with the and of the callout, and with the sigmoid . With separate covariances the terms no longer cancel, which gives QDA.

For Fisher’s criterion, write the numerator as with . Setting the gradient of the ratio to zero gives

The vector equals times the scalar . Dropping all scalars, , so . The scatter is times the pooled covariance, so this is the LDA direction.

Examples

(Easy) How Far From Approval

A bank scores loan applicants with . Here is income in tens of thousands of dollars and is years at the current job. A positive score means approval. One applicant has .

(Medium) A Hot Day Explains Some Vibration

A plant monitors pumps with two standardized sensors, vibration and motor temperature . Hot days raise both readings, so they are correlated within each class. Healthy pumps (class ) have mean , and faulty pumps (class ) have mean . Both classes share

and half the pumps are faulty.

(Hard) Vibration Alone Versus Fisher's Direction

An engineer for the same plant proposes to ignore temperature and threshold vibration alone, at its midpoint between the two class means.

See Also