liveBook · Manning

Similarity metric

As explained in Bayesian Optimization in Action

A similarity metric is a numerical rule for quantifying how similar two data points are.

A similarity metric is a numerical rule for quantifying how similar two data points are. In Gaussian processes, a kernel uses this idea to estimate how likely two inputs are to have similar labels. section 13.0

Comparing houses

A door-color rule assigns similarity 1 to houses with matching front-door colors and 0 otherwise. That metric misleads price prediction because house size matters more than door color. A better metric includes relevant factors such as location and living area. section 13.0

The RBF kernel converts the difference between two input values into a covariance between 0 and 1. Small differences produce high covariance; large differences produce low covariance. This works naturally when nearby values imply similar outcomes, but can fail when data has meaningful structure that raw value differences do not capture. section 13.2

Structured data exposes important limitations:

  • Images can be represented as 784-element tensors of pixel values, yet value-based similarity may not capture visual similarity between handwritten digits. section 13.2.2
  • A large RBF length scale makes higher covariances more likely, but does not by itself provide a representation suited to image structure. section 13.2.2
Figure 13.1 The covariance between houses computed by an inappropriate kernel. Because it looks only at the color of the front door, this kernel doesn’t produce appropriate covariances.

Compare how an inappropriate door-color kernel assigns covariance between houses. section 13.0

How Bayesian Optimization in Action covers it

How deep it goes
Defines similarity through kernels, explains RBF behavior, and stops short of developing neural-network representations.
Examples
Uses house prices, door colors, living area, MNIST image tensors, heat maps, and an RBF length-scale implementation.
What it assumes
Assumes Gaussian-process and covariance-function context while building intuition through concrete housing and image examples.
What you can do after
Evaluate whether a kernel's similarity notion matches the predictive features and structure of the data.
How it connects
Connects similarity metrics to Gaussian processes, covariance functions, kernels, RBF kernels, structured data, and neural networks.

Also explained in

Compare how 10 books explain similarity metric →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bayesian Optimization in Action. The section links point to the parts of the book it draws on.