liveBook · Manning

Classifier

As explained in Machine Learning Algorithms in Depth

A classification algorithm learns a mapping from inputs to discrete class outputs.

A classifier learns to assign an input to one of K discrete classes. Given labeled training pairs D = {(xᵢ, yᵢ)}, it learns a rule h that predicts a label for a new input. K = 2 gives binary classification; K > 2 gives multiclass classification. Unlike regression, the target is a class rather than a continuous value. section 5.1 section 1.1

Often the input first becomes a d-dimensional feature vector φ(x), giving a prediction h(φ(x)). The goal is not merely to match training labels: the rule must generalize to unseen examples. One direct loss is the misclassification rate, (1/n)∑ᵢ 1[h(φ(xᵢ)) ≠ yᵢ], where the indicator is one for a mistake and zero otherwise. Training seeks parameters that reduce loss; model selection also checks whether the chosen capacity underfits or overfits. section 1.1 section 5.1

Several classifiers implement this mapping in different ways:

  • A perceptron uses a linear decision boundary, θ·x + θ₀ = 0, and updates it when a labeled example is misclassified. section 5.2 section 5.8
  • A support vector machine seeks a maximum-margin boundary; training points on its margins are support vectors. Logistic regression computes class conditional density using a softmax function. section 5.8
  • Bernoulli naive Bayes represents each document word as present or absent. It assumes features are conditionally independent given the class, so their class-conditional density factors into one-dimensional terms. section 5.5
  • A CART classification tree recursively chooses feature thresholds to partition the input space. A leaf predicts by majority vote; split costs such as Gini impurity favor purer leaves, while limiting depth helps prevent overfitting. section 5.6

For binary predictions, a confusion matrix separates true positives, true negatives, false positives, and false negatives. Changing the classification threshold changes these counts. ROC curves plot true-positive rate against false-positive rate across thresholds; precision–recall curves provide another view of performance. section 5.2

Document classification with Bernoulli naive Bayes

Convert each document into indicators xᵢⱼ: 1 if word j occurs in document i, otherwise 0. Estimate class and word-presence parameters from labeled documents, then compare class scores for a new document under the conditional-independence assumption. An implementation uses tokenization, stop-word filtering, and the 20 Newsgroups dataset. section 5.5

Figure 5.1 Model selection to avoid overfitting or underfitting to training data
figure

Compare training and test loss as model capacity changes to see where a classifier underfits or overfits. section 5.1

How Machine Learning Algorithms in Depth covers it

How deep it goes
Develops supervised notation, loss, evaluation, model selection, and selected classifiers through derivations and from-scratch implementations.
Examples
Uses an iris perceptron and decision tree, plus Bernoulli naive Bayes on 20 Newsgroups documents.
What it assumes
Assumes prior computer-science fundamentals for implementation while defining labeled data, discrete classes, and feature-vector notation.
What you can do after
Build it from scratch using perceptron, Bernoulli naive Bayes, or CART, then assess predictions and generalization.
How it connects
Connects classification to supervised learning, feature vectors, misclassification loss, model selection, overfitting, confusion matrices, and decision boundaries.

Also explained in

Compare how 31 books explain classifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.