Classification

Classification (or categorization) is a task where inputs are compared to possible categories and assigned to the most likely one.

2D binary classification

The goal is to find a line or curve, called a decision boundary, that separates the two classes.

Example:

Fertilization predictions

In more complex cases, decision boundaries may be curved or fuzzy:

Complex fertilization predictions

Each region of the plot represents a decision region, and the dividing lines or curves are the decision boundaries.

When classes overlap, no perfect boundary exists:

When classes overlap, no perfect boundary exists

The final decision depends on our policy or which kinds of mistakes we are willing to accept:

Boundary policy

Classification decisions are guided by:

2D multiclass classification

Assigning one of several possible classes to an input is called multiclass classification.

Example:

2D multiclass classification

Each class forms a group, and decision boundaries separate the different groups.

New data is classified based on which group it falls into.

Multiclass classification

Multiclass problems can be solved by combining multiple binary classifiers, which are simpler and faster.

There are two popular methods.

One-Versus-Rest (OvR)

One-Versus-Rest (OvR) (or Binary Relevance) creates one binary classifier per class, where each classifier separates that class from all the other classes combined.

For example, with five classes (A–E):

Each classifier:

To classify a new sample, we run it through all classifiers and assign it to the class with the highest probability.

Pros:

Cons:

One-Versus-One (OvO)

One-Versus-One (OvO) creates a separate binary classifier for every possible pair of classes.

For example, with four classes (A–D), we need six classifiers (A vs B, A vs C, A vs D, B vs C, B vs D, C vs D):

One-Versus-One

When classifying a new sample, we run it through all pairwise classifiers, and each one casts a vote.

The class with the most votes becomes the final prediction.

Pros:

Cons:

Clustering (for unsupervised learning)

The general idea is to group the training set data into clusters, or similar chunks.

If the data has associated labels (supervised learning):

Clustering for supervised learning

If the data has no associated labels (unsupervised learning):

The freedom to choose the value of k can be both helpful and challenging:

For simple, low-dimensional data, the best k can be easy to see (k=5 gives the best result):

Clustering for unsupervised learning

For higher-dimensional or complex data, identifying the optimal k in advance is difficult.

All is not lost:

Dimensionality and density

In theory, adding more features (dimensions) to data should help classifiers perform better by giving them more information.

However, beyond a certain point, adding more features actually harms performance.

This effect is known as the curse of dimensionality.

As data gains more dimensions, it becomes harder for a model to find meaningful patterns or decision boundaries.

The curse of dimensionality

To learn a good decision boundary, a classifier needs a dense set of training samples.

With few data points, it's easy to draw many different boundaries that separate them, making it hard to choose one that generalizes well:

A classifier needs a dense set of training samples

Using a dataset of 10 eggs with features scaled between 0 and 1, we see that as we add more features, the density decreases exponentially:

Dimensions Explanation Image

1D

With only one feature (e.g., weight)

  • the data fits on a line from 0 to 1
  • dividing this line into 5 bins gives a density of 10 samples / 5 bins = 2 samples per bin on average
  • this is enough to learn a reasonable boundary

2D

With two features (e.g., weight and length)

  • the data fits a 2D square with 25 bins (5 × 5)
  • with still only 10 samples, density drops to 10 / (5 x 5) = 0.4
  • most bins are empty, allowing many possible boundaries

3D

With three (e.g., weight, length, and volume)

  • the data fits a 3D cube with 125 bins (5 × 5 × 5)
  • with still only 10 samples, density drops to 10 / (5 x 5 x 5) = 0.08
  • almost all bins are empty, leaving insufficient data to reliably learn boundaries

As the number of features (dimensions) increases while the number of samples stays fixed, the data becomes sparse. This is the curse of dimensionality.

The problem isn't that it's hard to separate the data, but that it's too easy: many different boundaries fit equally well, but most will perform poorly on unseen data.

The blessing of non-uniformity and the manifold hypothesis

What mitigates this issue is the blessing of non-uniformity (or blessing of structure):

The blessing of non-uniformity

Both the curse and blessing are empirical observations, and not hard facts we can always rely on.

In general, we can mitigate the curse of dimensionality by:

  1. collecting more data (more data increases density in the important regions)
  2. reducing the number of features (dimensionality reduction)

The curse of dimensionality is one reason why machine learning systems often need huge amounts of data for accurate learning.

High-dimensional weirdness

Imagine a sphere perfectly fitting inside a cube. How much of the cube's volume does it occupy?

Dimensions Explanation Image

1D

  • the cube is just a line segment, and the sphere is also a line segment that exactly matches
  • so the sphere fills 100% of the cube
A sphere in 1D

2D

  • the cube becomes a square and the sphere becomes a circle that touches the midpoint of each side
  • area of the circle divided by area of the square ≈ 0.8
  • circle fills ≈ 80% of the square
A sphere in 2D

3D

  • the cube is a regular cube and the sphere fits inside it, touching the center of each face
  • volume of the sphere divided by volume of the cube ≈ 0.5
  • sphere fills ≈ 50% of the cube
A sphere in 3D

As dimensions increase, the ratio keeps shrinking.

In higher dimensions, the volume of the largest hypersphere inside a hypercube drops rapidly. By the 10th dimension, the hypersphere occupies almost none of the hypercube's volume:

In higher dimensions, the volume of the largest hypersphere inside a hypercube drops rapidly

This is surprising, but mathematically correct.

High-dimensional geometry behaves in strange, unintuitive ways.

When working with multidimensional data, we cannot rely on intuition but must use precise mathematical reasoning.

Previous Information theory All ⏎ Next Training and testing

A Kemar Joint