Intro to Classification

Binary Logistic Regression Binary Logistic Regression Demo Kernel Methods RBF Kernel & Random Fourier Features Multinomial Logistic Regression

Binary Logistic Regression

In the regularized regression page, we modeled continuous-valued targets \(y \in \mathbb{R}\) using regularized linear regression. We now turn to the classification setting, where the output is a discrete label. The key shift is that instead of predicting a value directly, we model the probability that an input belongs to each class, connecting maximum likelihood estimation with the cross-entropy loss.

Consider a discriminative classification model \[ p(y \mid \mathbf{x}, \boldsymbol{\theta}), \] where \(\mathbf{x} \in \mathbb{R}^D\) is an input vector, \(y \in \{1, \ldots, C\}\) is the class label, and \(\boldsymbol{\theta}\) collects the model parameters.

Definition: Sigmoid Function and Binary Logistic Regression

The sigmoid (logistic) function \(\sigma : \mathbb{R} \to (0, 1)\) is defined by \[ \sigma(a) = \frac{1}{1 + e^{-a}}. \] For binary labels \(y \in \{0, 1\}\), binary logistic regression is the model \[ p(y \mid \mathbf{x}, \boldsymbol{\theta}) = \mathrm{Ber}\!\bigl(y \mid \sigma(\mathbf{w}^\top \mathbf{x} + b)\bigr), \] with \(\mathbf{w} \in \mathbb{R}^D\) the weight vector, \(b \in \mathbb{R}\) the bias, and \(\boldsymbol{\theta} = (\mathbf{w}, b)\) the parameters. The Bernoulli likelihood is \(\mathrm{Ber}(y \mid p) = p^y(1-p)^{1-y}\) for \(y \in \{0, 1\}\) and \(p \in [0, 1]\).

Equivalently, \[ p(y = 1 \mid \mathbf{x}, \boldsymbol{\theta}) = \sigma(a), \] where \(a\) is called the logit (or the pre-activation): \[ a = \mathbf{w}^\top \mathbf{x} + b = \log\!\left(\frac{p}{1-p}\right), \quad p = p(y = 1 \mid \mathbf{x}, \boldsymbol{\theta}). \] Throughout this page, \(\log\) denotes the natural logarithm.

The sigmoid function outputs the probability that the class label is \(y = 1\). Therefore, we define a decision rule that predicts \(y = 1\) if and only if class 1 is more likely than class 0: \[ \begin{align*} f(\mathbf{x}) &= \mathbb{1}\{p(y=1 \mid \mathbf{x}, \boldsymbol{\theta}) \gt p(y=0 \mid \mathbf{x}, \boldsymbol{\theta})\} \\\\ &= \mathbb{1}\!\left\{ \log \frac{p(y = 1 \mid \mathbf{x}, \boldsymbol{\theta})}{p(y = 0 \mid \mathbf{x}, \boldsymbol{\theta})} \gt 0 \right\} \\\\ &= \mathbb{1}\{a \gt 0\}. \end{align*} \] Here, \(\mathbb{1}\{\cdot\}\) denotes the indicator function, which returns 1 if the condition inside is true, and 0 otherwise: \[ \mathbb{1}\{\text{condition}\} = \begin{cases} 1 & \text{if condition is true,} \\ 0 & \text{otherwise.} \end{cases} \]

The underlying score function can be written as \[ s(\mathbf{x}; \boldsymbol{\theta}) = \mathbf{w}^\top \mathbf{x} + b, \] so that \(a = s(\mathbf{x}; \boldsymbol{\theta})\) and \(f(\mathbf{x}) = \mathbb{1}\{s(\mathbf{x}; \boldsymbol{\theta}) \gt 0\}\).

Since \(\mathbf{w}^\top \mathbf{x}\) is the inner product between the weight vector \(\mathbf{w}\) and the feature vector \(\mathbf{x}\), for \(\mathbf{w} \neq \mathbf{0}\) the decision boundary \(\{\mathbf{x} : \mathbf{w}^\top \mathbf{x} + b = 0\}\) is a hyperplane with normal vector \(\mathbf{w}\). The hyperplane lies at signed distance \(-b/\|\mathbf{w}\|\) from the origin, measured in the direction of \(\mathbf{w}\). The weight vector \(\mathbf{w}\) determines the orientation of the decision boundary, and the bias \(b\) shifts the boundary. Moreover, the norm \(\|\mathbf{w}\|\) controls how steeply \(\sigma(\mathbf{w}^\top \mathbf{x} + b)\) changes across the boundary. For a fixed decision boundary (that is, with \(\mathbf{w}\) and \(b\) scaled together), a larger norm yields a sharper transition between predicted classes and therefore more confident predictions at every point off the boundary.

For the derivations below we absorb the bias into the weights by appending a constant feature \(1\) to each training input \(\mathbf{x}_n\), so that \(\mathbf{x}_n, \mathbf{w} \in \mathbb{R}^{D+1}\) and \(a_n = \mathbf{w}^\top \mathbf{x}_n\).

To estimate the parameters \(\mathbf{w}\), we maximize the likelihood of the observed dataset \(\mathcal{D} = \{(\mathbf{x}_n, y_n)\}_{n=1}^N\). Equivalently, treating the examples as independent, we minimize the negative log-likelihood (NLL): \[ \begin{align*} \mathrm{NLL}(\mathbf{w}) &= - \frac{1}{N} \log p(\mathcal{D} \mid \mathbf{w}) \\\\ &= - \frac{1}{N} \log \prod_{n=1}^N \mathrm{Ber}(y_n \mid \mu_n) \\\\ &= - \frac{1}{N} \sum_{n=1}^N \log\!\left[ \mu_n^{y_n} (1-\mu_n)^{1-y_n} \right] \\\\ &= - \frac{1}{N} \sum_{n=1}^N \left[ y_n \log \mu_n + (1-y_n) \log(1-\mu_n) \right] \\\\ &= \frac{1}{N} \sum_{n=1}^N \mathbb{H}_{ce}(y_n, \mu_n), \end{align*} \] where \(\mu_n = \sigma(a_n) = \sigma(\mathbf{w}^\top \mathbf{x}_n)\) is the model's predicted probability of class 1, and \(\mathbb{H}_{ce}(y_n, \mu_n) = \mathbb{H}\bigl((y_n, 1 - y_n), (\mu_n, 1 - \mu_n)\bigr)\) is the cross entropy between the label distribution and the predicted one.

When the maximum likelihood estimate (MLE) exists, we find it by solving \[ \nabla_{\mathbf{w}} \mathrm{NLL}(\mathbf{w}) = \mathbf{0} \] via gradient-based optimization (in practice, using automatic differentiation).

The gradient of the NLL with respect to \(\mathbf{w}\) is \[ \begin{align*} \nabla_{\mathbf{w}} \mathrm{NLL}(\mathbf{w}) &= - \frac{1}{N} \sum_{n=1}^N \left[ y_n (1-\mu_n) \mathbf{x}_n - (1-y_n) \mu_n \mathbf{x}_n \right] \\\\ &= \frac{1}{N} \sum_{n=1}^N (\mu_n - y_n) \mathbf{x}_n. \end{align*} \] Equivalently, in matrix form, \[ \nabla_{\mathbf{w}} \mathrm{NLL}(\mathbf{w}) = \frac{1}{N} X^\top (\boldsymbol{\mu} - \mathbf{y}), \] where \(X \in \mathbb{R}^{N \times (D+1)}\) is the design matrix whose \(n\)th row is \(\mathbf{x}_n^\top\), and \(\boldsymbol{\mu}, \mathbf{y} \in \mathbb{R}^N\) are the vectors of \(\mu_n\) and \(y_n\), respectively. Each \(\mathbf{x}_n\) is weighted by its residual \(\mu_n - y_n\).

Derivation of the gradient of \(\mathrm{NLL}(\mathbf{w})\):

Recall the sigmoid function: \[ \sigma(a) = \frac{1}{1 + e^{-a}}. \] We compute its derivative with respect to \(a\): \[ \begin{align*} \frac{d\sigma}{da} &= \frac{d}{da}\,(1 + e^{-a})^{-1} \\\\ &= -1 \cdot (1 + e^{-a})^{-2} \bigl(-e^{-a}\bigr) \\\\ &= \frac{e^{-a}}{(1 + e^{-a})^2} \\\\ &= \left( \frac{1}{1 + e^{-a}}\right) \left(\frac{e^{-a}}{1 + e^{-a}}\right) \\\\ &= \sigma(a)\,\bigl(1 - \sigma(a)\bigr). \end{align*} \]

Since \(\mu_n = \sigma(a_n)\), we conclude: \[ \frac{\partial \mu_n}{\partial a_n} = \mu_n\,(1 - \mu_n). \]

For a single data point \((\mathbf{x}_n, y_n)\), let \[ \ell_n = -\bigl[y_n\log\mu_n + (1-y_n)\log(1-\mu_n)\bigr]. \] We compute: \[ \frac{\partial \ell_n}{\partial \mu_n} = -\Bigl(\frac{y_n}{\mu_n} - \frac{1 - y_n}{1 - \mu_n}\Bigr) = \frac{\mu_n - y_n}{\mu_n (1 -\mu_n)}. \] By the chain rule, \[ \begin{align*} \frac{\partial \ell_n}{\partial a_n} &= \frac{\partial \ell_n}{\partial \mu_n} \cdot \frac{\partial \mu_n}{\partial a_n} \\\\ &= \frac{\mu_n - y_n}{\mu_n (1 -\mu_n)} \cdot \mu_n\,(1 - \mu_n) \\\\ &= \mu_n - y_n. \end{align*} \] Also, since \(a_n = \mathbf{w}^\top \mathbf{x}_n\), \[ \frac{\partial a_n}{\partial \mathbf{w}} = \mathbf{x}_n. \] Combining: \[ \frac{\partial \ell_n}{\partial \mathbf{w}} = \frac{\partial \ell_n}{\partial a_n} \cdot \frac{\partial a_n}{\partial \mathbf{w}} = (\mu_n - y_n)\mathbf{x}_n. \] Summing over all \(N\) examples and dividing by \(N\) gives \[ \nabla_{\mathbf{w}} \mathrm{NLL}(\mathbf{w}) = \frac{1}{N}\sum_{n=1}^N (\mu_n - y_n)\,\mathbf{x}_n. \]

To verify convexity, we examine the Hessian: \[ \begin{align*} H(\mathbf{w}) &= \nabla_{\mathbf{w}}^2 \mathrm{NLL}(\mathbf{w}) \\\\ &= \frac{1}{N} \sum_{n=1}^N \mu_n(1-\mu_n)\,\mathbf{x}_n \mathbf{x}_n^\top \\\\ &= \frac{1}{N} X^\top S X, \end{align*} \] where \(S = \mathrm{diag}(\mu_1(1-\mu_1), \ldots, \mu_N(1-\mu_N))\).

For any \(\mathbf{v} \in \mathbb{R}^{D+1}\), \[ \begin{align*} \mathbf{v}^\top H(\mathbf{w}) \mathbf{v} &= \frac{1}{N} \mathbf{v}^\top X^\top S X \mathbf{v} \\\\ &= \frac{1}{N} (\mathbf{v}^\top X^\top S^{1/2})(S^{1/2} X \mathbf{v}) \\\\ &= \frac{1}{N} \| S^{1/2} X \mathbf{v} \|_2^2 \geq 0. \end{align*} \]

Thus, the Hessian \(H(\mathbf{w})\) is positive semi-definite, so the NLL is convex by the second-order condition for convexity. Every stationary point \(\mathbf{w}\) is therefore a global minimizer. To prove this, fix any \(\mathbf{w}'\). The restriction \(g(t) = \mathrm{NLL}(\mathbf{w} + t(\mathbf{w}' - \mathbf{w}))\) is a differentiable convex function of one variable, since a convex function restricted to a line is convex. Its derivative satisfies \(g'(0) = \nabla_{\mathbf{w}} \mathrm{NLL}(\mathbf{w})^\top (\mathbf{w}' - \mathbf{w}) = 0\), so the first-order characterization of convexity gives \(g(1) \geq g(0)\).

Note that \(H(\mathbf{w})\) is strictly positive definite only if the design matrix \(X\) has full column rank. In practice, \(H(\mathbf{w})\) can become ill-conditioned or singular for two common reasons. One is that the columns of \(X\) are linearly dependent or nearly so. The other is that the \(\mu_n\) are very close to 0 or 1 (near-perfect separation), in which case the corresponding diagonal entries of \(S\) become nearly zero.

Adding an \(\ell_2\) regularization term \(\frac{\lambda}{2}\|\mathbf{w}\|_2^2\) with \(\lambda \gt 0\) shifts the Hessian to a strictly positive definite matrix \(H(\mathbf{w}) + \lambda I\) and so restores numerical stability. The regularized objective is strictly convex and grows without bound as \(\|\mathbf{w}\|_2 \to \infty\), so a minimizer exists and is unique. Ridge regression uses a squared \(\ell_2\) penalty of the same kind in the linear case.

Binary Logistic Regression Demo

The demo works with two-dimensional inputs \(\mathbf{x} = (x_1, x_2)\). Given a linear score function \[ z = w_0 + w_1 x_1 + w_2 x_2, \] and the predicted probability \[ \sigma(z) = \frac{1}{1 + e^{-z}}, \] we minimize the average binary cross-entropy plus an \(\ell_2\) penalty on the weights (excluding the bias): \[ J_\lambda(\mathbf{w}) = - \frac{1}{N} \sum_{n=1}^N \left[ y_n \log \sigma(z_n) + (1-y_n) \log(1-\sigma(z_n)) \right] + \frac{\lambda}{2} \sum_{j=1}^2 w_j^2. \] Here \(\mathbf{w} = (w_0, w_1, w_2)\), the bias is \(w_0\), and \(z_n\) is the score of the training input \(\mathbf{x}_n\).

The learning rate controls the step size in each gradient descent update.

When \(\lambda = 0\), the objective \(J_0\) is the NLL. If the training data contain both classes and are linearly separable, the NLL has no minimizer. Indeed, take any \(\mathbf{w}\) whose decision rule classifies every training point correctly, with no point on the decision boundary. Replacing \(\mathbf{w}\) by \(c\,\mathbf{w}\) and letting \(c \to \infty\) drives every term of the cross-entropy to zero, so the infimum \(0\) is approached but never attained. Gradient descent therefore cannot converge to a minimizer, since none exists.

On such separable data, with \(\lambda = 0\) and a small enough learning rate, the loss keeps decreasing while \(\|(w_1, w_2)\|_2\) grows without bound. To see this in the demo above, set both the label noise and \(\lambda\) to \(0\), and keep pressing Train (Continue) while watching the weight-norm panel. Any \(\lambda \gt 0\) makes the objective strictly convex in \((w_0, w_1, w_2)\). Provided both classes occur in the data, the regularized objective then has a unique minimizer, so the norm curve flattens given enough iterations. The failure of the unregularized NLL to have a minimizer on separable data, invisible in the loss value alone, is a concrete reason to regularize whenever the data may be separable.

Kernel Methods

In many problems the original feature vectors \(\mathbf{x} \in \mathbb{R}^D\) are not linearly separable. One fix is to apply a nonlinear feature mapping \[ \phi : \mathbb{R}^D \to \mathbb{R}^P, \quad P \gg D, \] in the hope that the mapped data \(\{\phi(\mathbf{x}_n)\}\) become separable. But computing and storing the mapped data explicitly is costly when \(P\) is large, and impossible for an infinite-dimensional feature map, such as the one behind the RBF kernel below.

Alternatively, if a learning algorithm depends only on inner products \(\langle \phi(\mathbf{x}), \phi(\mathbf{x}') \rangle\), we can invoke the kernel trick. The trick replaces each inner product with a positive definite kernel \(K(\mathbf{x}, \mathbf{x}')\) that computes \(\langle \phi(\mathbf{x}), \phi(\mathbf{x}') \rangle\) implicitly. No \(\phi\) is ever constructed. The full theory of when such a representation exists, and the canonical Hilbert space it lives in, is developed in our RKHS & Kernel Methods page via the Moore-Aronszajn theorem.

Concretely, we build the kernel (Gram) matrix \[ \mathbf{K}_{ij} = K(\mathbf{x}_i, \mathbf{x}_j), \quad i,j = 1, \ldots, N, \] and run our algorithm using \(\{\mathbf{K}_{ij}\}\) instead of \(\{\phi(\mathbf{x}_i)\}\).

The kernel matrix has \(N^2\) entries, so for large \(N\) its storage and computation become the bottleneck. Two common remedies are:

RBF Kernel & Random Fourier Features

Among the many valid kernels, a widely used choice is the RBF (Gaussian) kernel: \[ K_{\mathrm{RBF}}(\mathbf{x}, \mathbf{x}') = \exp\!\Bigl(-\tfrac{\|\mathbf{x} - \mathbf{x}'\|^2}{2\sigma^2}\Bigr), \] which corresponds to an infinite-dimensional feature map. Here, \(\sigma \gt 0\) is the bandwidth parameter, not the sigmoid function. (RBF stands for "radial basis function." See Gaussian processes for more general parameterizations.)

Every shift-invariant continuous positive definite kernel on \(\mathbb{R}^D\) admits an integral representation as the Fourier transform of a finite non-negative measure. This is Bochner's theorem, which we state without proof. For the RBF kernel, the measure is the Gaussian distribution \(\mathcal{N}(\mathbf{0}, \sigma^{-2} I)\) itself, which gives \[ K_{\mathrm{RBF}}(\mathbf{x}, \mathbf{x}') = \mathbb{E}_{\boldsymbol{\omega} \sim \mathcal{N}(\mathbf{0}, \sigma^{-2} I)}\!\bigl[\cos(\boldsymbol{\omega}^\top (\mathbf{x} - \mathbf{x}'))\bigr]. \] We do not prove this identity either, and we take it as the starting point for an algorithmic approximation.

To approximate the kernel, we sample \(D'\) frequencies \(\{\boldsymbol{\omega}_k\} \sim \mathcal{N}(\mathbf{0}, \sigma^{-2} I)\) and phases \(\{\eta_k\} \sim \mathrm{Uniform}[0, 2\pi]\), all independent, and define \[ \phi_{\mathrm{RFF}}(\mathbf{x}) = \sqrt{\frac{2}{D'}}\, \bigl[\cos(\boldsymbol{\omega}_1^\top \mathbf{x} + \eta_1), \ldots, \cos(\boldsymbol{\omega}_{D'}^\top \mathbf{x} + \eta_{D'})\bigr] \in \mathbb{R}^{D'}. \]

For each \(k\), the identity \(2\cos\alpha\cos\beta = \cos(\alpha - \beta) + \cos(\alpha + \beta)\) gives \[ \begin{align*} &\mathbb{E}_{\boldsymbol{\omega}_k, \eta_k}\!\bigl[2\cos(\boldsymbol{\omega}_k^\top \mathbf{x} + \eta_k)\cos(\boldsymbol{\omega}_k^\top \mathbf{x}' + \eta_k)\bigr] \\\\ &= \mathbb{E}_{\boldsymbol{\omega}_k}\!\bigl[\cos(\boldsymbol{\omega}_k^\top (\mathbf{x} - \mathbf{x}'))\bigr] + \mathbb{E}_{\boldsymbol{\omega}_k, \eta_k}\!\bigl[\cos(\boldsymbol{\omega}_k^\top (\mathbf{x} + \mathbf{x}') + 2\eta_k)\bigr] \\\\ &= K_{\mathrm{RBF}}(\mathbf{x}, \mathbf{x}'), \end{align*} \] since the second expectation vanishes, with \(2\eta_k\) ranging over two full periods.

Hence \(\phi_{\mathrm{RFF}}(\mathbf{x})^\top \phi_{\mathrm{RFF}}(\mathbf{x}')\) is the average of \(D'\) independent unbiased estimates of \(K_{\mathrm{RBF}}(\mathbf{x}, \mathbf{x}')\). The estimates are identically distributed and bounded by \(2\), so their variance is finite, and by the weak law of large numbers their average converges in probability to the kernel value as \(D'\) grows. Thus \[ \phi_{\mathrm{RFF}}(\mathbf{x})^\top \phi_{\mathrm{RFF}}(\mathbf{x}') \approx K_{\mathrm{RBF}}(\mathbf{x}, \mathbf{x}'), \] so we can train a regularized linear model on these \(D'\)-dimensional features at cost linear in \(N\) without forming the \(O(N^2)\) kernel matrix.

Multinomial Logistic Regression

When there are more than two classes (\(C \gt 2\)), we generalize the sigmoid to the softmax function.

Definition: Softmax Function and Multinomial Logistic Regression

For inputs \(\mathbf{x} \in \mathbb{R}^D\) and class-specific weights \(\{\mathbf{w}_c, b_c\}_{c=1}^C\), the softmax function defines a probability distribution over \(C\) classes: \[ p(y = c \mid \mathbf{x}, \boldsymbol{\theta}) = \frac{\exp(\mathbf{w}_c^\top \mathbf{x} + b_c)} {\sum_{c'=1}^C \exp(\mathbf{w}_{c'}^\top \mathbf{x} + b_{c'})}, \quad c = 1, \ldots, C. \] When \(C = 2\), this reduces to the sigmoid function \(\sigma(a)\) of binary logistic regression, with \(a = (\mathbf{w}_1 - \mathbf{w}_2)^\top \mathbf{x} + b_1 - b_2\).

The softmax has an exact optimality property. Fix an input \(\mathbf{x}\), and call \(\mathbf{w}_c^\top \mathbf{x} + b_c\) the score of class \(c\), as in the binary case. Among all probability vectors \(\mathbf{r} = (r_1, \ldots, r_C)\) on the \(C\) classes, the vector of class probabilities above is the only one that maximizes \[ \sum_{c=1}^C r_c \bigl( \mathbf{w}_c^\top \mathbf{x} + b_c \bigr) - \sum_{c=1}^C r_c \log r_c, \] the expected score plus the entropy of \(\mathbf{r}\), where, as throughout the page, \(\log\) is the natural logarithm, with the convention \(0 \log 0 = 0\). The maximal value is \(\log \sum_{c=1}^C \exp(\mathbf{w}_c^\top \mathbf{x} + b_c)\). The theorem that negative entropy and log-sum-exp are conjugate, applied to the vector of scores, gives both facts.

For a temperature \(\tau \gt 0\), the Gibbs variational principle with temperature applies to the same scores, with the uniform distribution on the classes as the reference distribution. Its objective then differs from the expected score plus \(\tau\) times the entropy only by the constant \(\tau \log C\), because the KL divergence of \(\mathbf{r}\) from the uniform distribution is \(\log C\) minus the entropy of \(\mathbf{r}\). The two objectives therefore have the same unique maximizer, which the principle gives as the class probabilities above with every score divided by \(\tau\).

We fit \(\boldsymbol{\theta} = \{\mathbf{w}_c, b_c\}\) by minimizing the average cross-entropy loss \[ \mathrm{NLL}(\boldsymbol{\theta}) = -\frac{1}{N}\sum_{n=1}^N \sum_{c=1}^C \mathbb{1}\{y_n = c\}\,\log p(y_n = c \mid \mathbf{x}_n, \boldsymbol{\theta}). \]

The gradient has a similarly clean form: \[ \frac{\partial \mathrm{NLL}}{\partial \mathbf{w}_c} = \frac{1}{N}\sum_{n=1}^N \Bigl[p(y_n = c \mid \mathbf{x}_n, \boldsymbol{\theta}) - \mathbb{1}\{y_n = c\}\Bigr]\,\mathbf{x}_n, \] and the NLL can be decreased via batch or mini-batch gradient descent.

The Hessian \(H\) of the NLL in \((\mathbf{w}_1, \ldots, \mathbf{w}_C)\), with the biases absorbed as before, has \((D+1) \times (D+1)\) blocks \[ \frac{\partial^2 \mathrm{NLL}}{\partial \mathbf{w}_c \, \partial \mathbf{w}_{c'}} = \frac{1}{N}\sum_{n=1}^N p_{nc}(\delta_{cc'} - p_{nc'})\,\mathbf{x}_n \mathbf{x}_n^\top, \] where \(p_{nc} = p(y_n = c \mid \mathbf{x}_n, \boldsymbol{\theta})\). For any \(\mathbf{v} = (\mathbf{v}_1, \ldots, \mathbf{v}_C)\), we write \(u_{nc} = \mathbf{v}_c^\top \mathbf{x}_n\) and obtain \[ \begin{align*} \mathbf{v}^\top H \mathbf{v} &= \frac{1}{N}\sum_{n=1}^N \Bigl[\sum_{c=1}^C p_{nc} u_{nc}^2 - \Bigl(\sum_{c=1}^C p_{nc} u_{nc}\Bigr)^2\Bigr] \\\\ &\geq 0, \end{align*} \] since each bracket is the variance of \(u_{n\cdot}\) under the distribution \(p_{n\cdot}\). The multiclass NLL is therefore convex.

Logistic regression, both binary and multinomial, is a linear classifier. With the decision rule that predicts a class of largest probability, the decision boundaries are piecewise linear. Each boundary between two classes \(c, c'\) with \(\mathbf{w}_c \neq \mathbf{w}_{c'}\) lies in a hyperplane of the original feature space. The kernel trick extends the classifier to nonlinear boundaries without explicitly constructing high-dimensional features.