Study Vault Search notes, aliases and full text
Graph
ConceptDBISAI-written · not yet proofread

Linear Classifier

Also Decision Boundary · Linear Separability

A binary classifier that assigns x ∈ ℝ^d to one class iff w·x > b, so that the two classes are separated by the hyperplane H = {x | w·x = b}.

Formula#

Distance of a point to the hyperplane:

dist⁡(x,H)=∣w⋅x−b∣∥w∥,∥w∥=∑iwi2.\operatorname{dist}(x, H) = \frac{|w \cdot x - b|}{\|w\|}, \qquad \|w\| = \sqrt{\textstyle\sum_i w_i^2}.
ProofDerivation

ww is orthogonal to HH: for y,y′∈Hy, y' \in H, w⋅(y−y′)=b−b=0w \cdot (y - y') = b - b = 0. Write x=y+t⋅w∥w∥x = y + t \cdot \frac{w}{\|w\|} with y∈Hy \in H the foot of the perpendicular and ∣t∣=dist⁡(x,H)|t| = \operatorname{dist}(x, H). Then w⋅x−b=(w⋅y−b)+tw⋅w∥w∥=t ∥w∥w \cdot x - b = (w \cdot y - b) + t \frac{w \cdot w}{\|w\|} = t \, \|w\|, so ∣t∣=∣w⋅x−b∣/∥w∥|t| = |w \cdot x - b| / \|w\|.

Bias as an extra component. Appending a constant 11 to xx and −b-b to ww gives w⋅x−b=(w,−b)⋅(x,1)w \cdot x - b = (w, -b) \cdot (x, 1), a hyperplane through the origin in Rd+1\mathbb{R}^{d+1}. Logistic Regression uses this form (“bias term already included in XX”).

Properties#

  • ww is the normal vector of HH; the sign of w⋅x−bw \cdot x - b tells on which side xx lies, w⋅x−b∥w∥\frac{w \cdot x - b}{\|w\|} is the signed distance.
  • HH contains the origin iff b=0b = 0, since w⋅0=0w \cdot 0 = 0 (exam WS 22/23, Task 3.2).
  • Scaling invariance: (λw,λb)(\lambda w, \lambda b) for λ>0\lambda > 0 defines the same classifier and the same HH.
  • XOR is not linearly separable. Points (1,1),(2,2)(1,1), (2,2) in class 0 and (2,1),(1,2)(2,1), (1,2) in class 1: a separating (w,b)(w, b) would need w⋅(2,1)>bw \cdot (2,1) > b and w⋅(1,2)>bw \cdot (1,2) > b, so w⋅(3,3)>2bw \cdot (3,3) > 2b, and also w⋅(1,1)≤bw \cdot (1,1) \le b, w⋅(2,2)≤bw \cdot (2,2) \le b, so w⋅(3,3)≤2bw \cdot (3,3) \le 2b. Contradiction. Hence no linear classifier reaches precision and recall 11 on both classes (exam WS 22/23, Task 3.3).
  • Classifiers that are linear:
    • the Perceptron learns (w,b)(w, b) directly and finds a separating one if the data is linearly separable;
    • Logistic Regression predicts the positive class iff σ(w⋅x)>1/2  ⟺  w⋅x>0\sigma(w \cdot x) > 1/2 \iff w \cdot x > 0 (Sigmoid);
    • the Naive Bayes Classifier with two classes is linear in the word-count vector, with wi=log⁡(pwiX/pwiY)w_i = \log(p_{w_i X}/p_{w_i Y}) and b=log⁡(pY/pX)b = \log(p_Y/p_X).

Example#

Sources#

  • Not covered by a WS 25/26 lecture. Source: the former Information Retrieval exams.
  • Exam WS 21/22, Task 5.2 (not published) (distance to a plane)
  • Exam WS 22/23, Task 3.2 (not published) (origin, distance), Task 3.3 (not published) (XOR, F1F_1)
  • Exam WS 16/17, Task 4.3–4.4 (not published) (ww and bb of Naive Bayes)
  • Exam WS 15/16, Task 4 (not published) (convention w⋅x−bw \cdot x - b)

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only